SharePoint 2010 从模块 "XX" 初始化文件 "XX" 失败:指定的列表不存在

      最近做一个小项目,在部署wsp包的过程中,激活feature的时候提示错误:

         Failed to instantiate file "" from module "" The specified list does not exist

        在网上查了些资料,都只根据字面的意思告之这个list不存在,而我的feature receiver里已经加入了创建list的代码,经过独立测试,创建list的代码没有问题。

 

         然后通过designer查看网站,却发现有和list同名的文件夹被创建,经过查阅资料,发现是因为在工程文件里的一个module中的Elements.xml的Url属性指向了该list,如果该list不存在,会自动生成一个与list同名的文件夹,这个文件夹是副产物,需要删掉这个文件夹。

 

        项目需求是创建一个页面,通过elements.xml里的Url属性,和File的Type属性,将该页面可视化保存到list里,这样可以通过SharePoint list的各种feature来操作页面,比如权限控制,下载,更新,上传等等。

 

        最后经过分步调式,发现最终原因,在feature里执行部署该module的顺序优先于运行feature receiver里的创建list的代码(详细生命周期请见下图),解决方案是:创建2个feature,第一个feature负责创建list,第二个feature负责加载module,然后在第二个feature设置Dependency,依赖于第一个feature。

SharePoint Feature 生命周期:


阶段 事件 命令 界面操作
Add to solution store   AddSolution  
Deployment to server/farm FeatureInstalled DeploySolution Central Admin > Operations > Solution Management
Activation to SCOPE FeatureActivated

ActivateFeature

or

 
Upgrade FeatureUpgrading (new for 2010) UpgradeSolution  
Deactivation from SCOPE FeatureDeactivating

On RetractSolution if still activated when called

or

DeactivateFeature

 
Retraction from server/farm FeatureUninstalling RetractSolution Central Admin > Operations > Solution Management
Delete from solution store DeleteSolution

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值