I have created a simple SharePoint 2013 solution and added event receiver. When I am in visual studio, i hit F5, solution is deployed and event receiver works. However, when I publish the solution (.wsp), add it into solutions, activate the solution, activate the feature in the site collection admin, it just does not work.
I found out, that after I use "deploy" in VS13, then event receiver starts working just like it was working during debugging. Do you have any idea why please? :) I am banging my head what could be wrong...
thank you very much
Here is my very crude code:
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
base.EventFiringEnabled = false;
String curListName = properties.ListTitle;
if (curListName == "ListOfAddedItem")
{
string internalName = properties.ListItem.Fields["Title"].InternalName;
//Turn off event firing during item update
base.EventFiringEnabled = false;
SPListItem item = properties.ListItem;
item[internalName] = "E:" + item[internalName];
//getting second web
string siteUrl = "issserver/sites/devsite";
try
{
SPSite site = new SPSite(siteUrl);
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
site.AllowUnsafeUpdates = true;
SPList list = web.Lists["OtherList"];
list.Fields[SPBuiltInFieldId.ID].ReadOnlyField = false;
SPListItem Item = list.Items.Add();
Item[SPBuiltInFieldId.ID] = item["ID"];
Item["Title"] = item["Title"];
Item.Update();
list.Fields[SPBuiltInFieldId.ID].ReadOnlyField = true;
}
}
catch {
item[internalName] = "cannot connect to the site";
}
item.Update();
//clientContext.ExecuteQuery();
base.EventFiringEnabled = true;
}
}