的实例,我有以下激活码:“激活功能”:对象引用未设置到对象
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
// Create a new list and populate it.
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
web.Lists.Add("Projects", "Projects That are currently being worked on.", SPListTemplateType.GenericList);
web.Update();
// Add the new list and the new content.
SPList projectList = web.Lists["Projects"];
projectList.Fields.Add("Name", SPFieldType.Text, false);
projectList.Fields.Add("Description", SPFieldType.Text, false);
projectList.Update();
//Create the view? - Possibly remove me.
System.Collections.Specialized.StringCollection stringCollection =
new System.Collections.Specialized.StringCollection();
stringCollection.Add("Name");
stringCollection.Add("Description");
//Add the list.
projectList.Views.Add("Project Summary", stringCollection, @"", 100,
true, true, Microsoft.SharePoint.SPViewCollection.SPViewType.Html, false);
projectList.Update();
}
}
哪些应该通过并添加新的列表称为项目及其相关视图。如何过上运行的应用程序时,我得到:
“激活功能”:对象引用不设置到 对象的实例
我的问题是:
- 这是为什么发生了什么?激活发生在站点级别。我是“开发”网站的“admin”。
- 我应该每次检查以确保此列表不存在? (每次,指每次我打部署)
哪条线抛出异常?这应该是绝对的第一件事,你应该把它包括在问题中。 –
它实际上并没有说哪一行,它是0行,0行,0行,CustomerCommunicationProject。 @jonSkeet – TheWebs
您没有完整的堆栈跟踪?伊克。你能通过调试器中的代码吗? (如果你当前正在运行Release版本,请试试Debug版本,这可能会给你更多的信息。) –