开发者

SharePoint 2010 Email Event Handler produces error "Could not load file or assembly...", list stops working

Following many blogs, I have the code below. However, once I registered by event handler and restarted the SharePoint Timer service, when I send an email to the list, it no longer displays the email and I get the error below.

I tried:

  • Changing the assembly version each time before deploying.
  • Restarting IIS, SharePoint Timer Service.
  • Had my IT department give "Users" account rights to my a开发者_开发问答ssembly in the GAC (other blog suggested).

Code:

public class EventReceiver1 : SPEmailEventReceiver
{
    /// <summary>
    /// The list received an e-mail message.
    /// </summary>       
    public override void EmailReceived(SPList oList, SPEmailMessage oMessage, string strReceiverData)
    {
        SPListItem oListItem = oList.Items.Add();
        oListItem["FaxNumber"] = oMessage.Headers["Subject"];
        //oListItem["Body"] = oMessage.HtmlBody;
        oListItem["MessageBody"] = oMessage.Headers["Subject"];
        oListItem.Update();
    }
}

Error:

Could not load file or assembly 'TestEventReceiverProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=defdab4ceab73dcb' or one of its dependencies. The system cannot find the file specified.

Also, when I restarted the SP service, I get an error "An unhandled exception (System.Security.Cryptography.CrytographicException') occured in OWSTIMER.EXE [6760]"


open project properties window. select Build tab Change it to ‘Any CPU’ Save your changes. Compile your project and deploy

If the assemblies are in the GAC and the Visual Studio debugger can't see the debugging symbols (aka: *.pdb). Unless you've gone through the trouble of setting up a symbol store where all your PDBs are going, you'll need to put the debugging symbols in the same location as the assembly. The trick is finding the folder that contains your DLL in the GAC.

The c:\windows\assembly folder is not a real folder, it's a virtual folder. To get to the REAL folder, do the following:

Start » Run %systemroot%\assembly\gac [ENTER] This will open the GAC folder. Now, poke around until you find a folder that looks like this (you might need to jump up one folder and dive into the MSIL folder): [assembly file name -.DLL extention][assembly version in format of #.#.#.#]__[assembly public key token].

When you find that folder, open it up and you'll see your assembly and you'll confirm if your assembly has been deployed properly. You can simply drag and drop assembly

Perform and IISreset, Reset the timer job and you're good to test again

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜