将 SharePoint 布局 ASP .NET 程序集部署到 GAC 中

发布于 2024-10-17 22:05:16 字数 994 浏览 0 评论 0原文

我目前正在重写旧版 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

转角预定愛 2024-10-24 22:05:16

您需要将 Inherits= 与完全限定的程序集名称一起使用...

Inherits="MyAssembly.MyNamespace.MyClass, MyAssembly, version=1.0.0.0, culture=neutral, publickeytoken=123456789"

You need to use Inherits= with the fully qualified assembly name...

Inherits="MyAssembly.MyNamespace.MyClass, MyAssembly, version=1.0.0.0, culture=neutral, publickeytoken=123456789"
不气馁 2024-10-24 22:05:16

结果该程序集位于 SharePoint bin 文件夹中,这就是加载它时未指定完全限定名称的原因。 但是,将其从 GAC 中删除会产生另一个问题:

请求“Microsoft.SharePoint.Security.SharePointPermission、Microsoft.SharePoint.Security、Version=12.0.0.0、Culture=neutral、PublicKeyToken=71e9bce111e9429c”类型的权限失败

这很有趣,因为从 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:

Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文