将 SharePoint 布局 ASP .NET 程序集部署到 GAC 中
我目前正在重写旧版 SharePoint 应用程序,需要弄清楚如何部署它。
该应用程序本身是具有多种功能的 SharePoint 解决方案,包括 Web 部件和带有一些代码的简单网页。
有一个网页旨在部署在 layouts
子文件夹中。
在生产环境中,layouts
子目录中没有代码隐藏,只有.aspx
文件。
据我了解,相应的代码隐藏程序集是从 GAC 加载的。确实,它就在那里。
但是,页面代码不包含要求其在 GAC 中查找的 <%@ Assembly %>
指令,也不指定完全限定名称:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BadWolf._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- -->
</html>
那么此页面如何定位它在生产环境中的代码汇编? 我需要将相同的代码部署到不同的服务器,但如果我不指定 <%@ Assembly %>
SharePoint 会给出未知错误,在日志中表示如下:
Exception Type: System.Web.HttpException
Exception Message: Could not load type 'BadWolf._Default'.
我错过了什么?是否有任何特殊的配置、任何特殊的设置等等?
I'm currently rewriting a legacy SharePoint application and I need to figure out how to deploy it.
The application itself is SharePoint solution with several features, including webparts and simple web pages with some code.
There is a webpage that is designed to be deployed in layouts
subfolder.
In production environment, there is no codebehind in layouts
subdirectory, just the .aspx
file.
I understand that corresponding codebehind assembly is loaded from GAC. Indeed, it is there.
However the page code doesn't contain <%@ Assembly %>
directive that would ask it look in GAC, nor does it specify fully-qualified name:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BadWolf._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- -->
</html>
So how does this page locate its code assembly in the production environment? I need to deploy the same code to a different server but if I don't specify <%@ Assembly %>
SharePoint gives me Unknown Error, which is represented in logs as follows:
Exception Type: System.Web.HttpException
Exception Message: Could not load type 'BadWolf._Default'.
What did I miss? Is there any special config, any special setting, whatever?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 Inherits= 与完全限定的程序集名称一起使用...
You need to use Inherits= with the fully qualified assembly name...
结果该程序集位于 SharePoint
bin
文件夹中,这就是加载它时未指定完全限定名称的原因。 但是,将其从 GAC 中删除会产生另一个问题:这很有趣,因为从 GAC 或
中删除程序集bin
文件夹使其无法使用(或者需要我不寻求的额外配置),并且我不确定实际正在加载哪个。我想我会坚持保留程序集在 GAC 中(获得完全信任)并指定完全限定名称。
Turned out the assembly was in SharePoint
bin
folder, that's why it was loaded without specifying the fully qualified name. However removing it from GAC yielded another issue:This is funny because removing the assembly from either GAC or
bin
folder makes it unusable (or else requiring additional configuration which I seek not), and I'm not sure which one is actually being loaded.I think I'll stick with keeping assembly in GAC (to have full trust) and specifying fully qualified name.