Does a SharePoint EventReceiver have to be installed in the GAC, and if so do all dependent assemblies have to as well?

前端 未结 2 1837
天涯浪人
天涯浪人 2021-02-10 12:35

My company ships a product that among other things registers SharePoint EventReceiver on SPLists, monitoring for changes. I\'ve been registering it in the GAC where it runs just

相关标签:
2条回答
  • 2021-02-10 12:49

    Deployment of SharePoint EventReceiverwould not be possible in Bin. it has to be done in GAC only. I'm not sure what the exact reason is but may be it has to do something with code security.

    0 讨论(0)
  • 2021-02-10 13:04

    Event receiver assemblies cannot be installed only in "bin", because this way the .net framework could not find them.

    When your assembly is loaded from "bin" it is because assembly loader uses probing to locate the assembly. First it looks in GAC, then looks for directory called "bin" under the current working directory.

    Hence all code you use to run the web interface - codebehind for ASPX pages, web services etc, can be placed in inetpub..../bin because the working directory of your web application is there.

    However, workflows and scheduled "timer jobs" are executed by the OWSTIMER.exe, which is a Windows Service. As a typical windows service, it has its working directory somewhere in c:\windows.

    It means, if you place your assembly somewhere in inetpub...\bin, it will not be found by the owstimer.

    Hence, shared assemblies like event handlers have to be deployed to GAC.

    0 讨论(0)
提交回复
热议问题