SharePoint EventReceiver 是否必须安装在 GAC 中,如果是,所有依赖程序集也必须安装? [英] Does a SharePoint EventReceiver have to be installed in the GAC, and if so do all dependent assemblies have to as well?

查看:13
本文介绍了SharePoint EventReceiver 是否必须安装在 GAC 中,如果是,所有依赖程序集也必须安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司推出了一种产品,该产品在 SPList 上注册 SharePoint EventReceiver,监控更改.我一直在 GAC 中注册它,它运行得很好.但是,我们的一位客户对我们在 GAC 中安装的程序集表示不满,并希望我们将二进制文件移动到 SharePoint BIN 目录,并执行该方案工作所需的其他安全/信任伏都教.

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 fine. However, one of our customers has expressed unhappiness with our assembly being installed in the GAC and wishes us to move our binaries to the SharePoint BIN directory and do the other security/trust voodoo that is required for that scenario to work.

当我尝试注册不在 GAC 中的事件接收器时,我收到非常具体的异常,其消息为:事件接收器程序集不在 GAC 中."我将此解释为 SharePoint 要求在 GAC 中安装事件接收器.此外,我在 MSDN 上找到了这个:http://msdn.microsoft.com/en-us/library/ff407965.aspx:事件接收器和处理事件"部分说明

When I try to register an event receiver that is not in the GAC, I get the very specific exception whose message reads: "The event receiver assembly is not in the GAC." I interpret this as SharePoint requiring event receivers to be installed in the GAC. Furthermore, I found this on MSDN: http://msdn.microsoft.com/en-us/library/ff407965.aspx: the section "Event Receivers and Handling Events" states

SharePoint Foundation 事件处理程序是自定义的编译模块其调用为的托管代码由特定事件触发您已指定.事件处理代码被编译成一个 .dll 文件和部署到 GAC.

SharePoint Foundation event handlers are a compiled module of custom managed code whose invocation is triggered by a specified event that you have specified. Event handler code is compiled into a .dll file and deployed to the GAC.

这再次暗示但并未完全说明 GAC 安装是必需的.是否有人确切知道答案,以便我可以回到客户那里解释我们的 GAC 要求?

This again implies but does not full-out state that the GAC installation is a requirement. Does someone know the answer for this for certain, so I can go back to the customer and explain our GAC requirement?

现在的后续问题是:如果我在 GAC 中有一个程序集,并且我静态链接"到其他程序集——即我没有使用 Assembly.Load() 显式地动态加载它们——那么那些其他程序集还必须驻留在 GAC 中吗?

The followup question is now: if I have an assembly in the GAC, and I "statically link" to other assemblies -- i.e. I don't explictly dynamically load them with Assembly.Load() -- then those other assemblies must also reside in the GAC?

推荐答案

事件接收器程序集不能只安装在bin"中,因为这样 .net 框架找不到它们.

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

当您的程序集从b​​in"加载时,这是因为程序集加载器使用探测来定位程序集.首先在GAC中查找,然后在当前工作目录下查找名为bin"的目录.

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.

因此,您用于运行 Web 界面的所有代码 - ASPX 页面、Web 服务等的代码隐藏都可以放在 inetpub..../bin 中,因为您的 Web 应用程序的工作目录在那里.

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.

但是,工作流和计划的计时器作业"由 OWSTIMER.exe 执行,这是一个 Windows 服务.作为典型的 Windows 服务,它的工作目录位于 c:windows 中.

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.

这意味着,如果您将程序集放在 inetpub...in 中的某个位置,则 owstimer 将找不到它.

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

因此,必须将事件处理程序等共享程序集部署到 GAC.

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

这篇关于SharePoint EventReceiver 是否必须安装在 GAC 中,如果是,所有依赖程序集也必须安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆