我似乎无法在调试时激活我的EventReceiver。我在GAC进行调试。
我不是sharepoint或SP Objects的专家。
当用户更改我创建的下拉框中的值时,我想做点什么
Dropdownbox
[ChoiceField(Name = F.Adgang, DisplayName = "Adgang", Required = true, DefaultValue = "Alle", Choices = new string[] { "Alle", "Kun indehavere" })]
public bool Adgang
{
get { return G(); }
set { S(value); }
}
Model.cs
public class Model : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
site.RootWeb.CreateContentType<CourseAndEvent>();
site.RootWeb.CreateContentType<DanboligNewsPage>();
using (SPWeb web = site.OpenWeb())
{
var list = web.Lists[""];
var e = list.EventReceivers.Add(Guid.NewGuid());
e.Name = "test_All";
e.Type = SPEventReceiverType.ItemAdded | SPEventReceiverType.ItemDeleted | SPEventReceiverType.ItemDeleting;
e.Assembly = typeof(NewsReceiver).Assembly.FullName;
e.Class = typeof(NewsReceiver).FullName;
e.SequenceNumber = 10;
e.Update();
list.Update();
web.Update();
}
}
}
NewsReceiver.cs
class NewsReceiver : SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
SPListItem item = properties.ListItem;
string folderName = item["Name"].ToString();
string folderUrl = SPUtility.ConcatUrls(SPUtility.ConcatUrls(item.Web.Url, item.ParentList.RootFolder.Url), folderName);
SPFile file = item.File;
}
public override void ItemDeleting(SPItemEventProperties properties)
{
base.ItemDeleting(properties);
}
public override void ItemDeleted(SPItemEventProperties properties)
{
base.ItemDeleted(properties);
}
}
任何人都可以告诉我为什么在调试时没有任何ItemEvents没有触发,?
答案 0 :(得分:0)
我假设您将调试器附加到w3wp.exe。你确定你有合适的吗? 另外,您是否已查看有关调试事件接收器的this MSDN page? (陈旧但相关)
您是否确保将事件接收器附加到列表或包含它的站点?请参阅here。
答案 1 :(得分:0)
尝试在代码中的某处设置以下代码行。它将启动调试器:
System.Diagnostics.Debugger.Launch();
但如果你没有将EventReceiver正确地附加到你想要的对象上,它将无济于事。我还希望用SharePoint Manager检查一下,看看EventReceivers是否正确连接/注册。