Sharepoint 母版页的 WSPBuilder 和代码隐藏

发布于 2024-07-23 13:28:19 字数 596 浏览 9 评论 0原文

我在 Visual Studio 中为自定义母版页创建了一个代码隐藏文件。 我手动连接了所有东西; 安全控制和自定义 CAS 策略。 一切都很好!

然后我想使用 WSPBuilder 将其放入共享点解决方案中,以实现更好的部署。 我创建了 WSP 解决方案,添加了类文件并将输出目录更改为 bin 文件夹。 然后,我构建了解决方案并部署了它,确保更改母版页上的页面指令以反映新的程序集名称。

现在,当我去查看共享点站点时,我收到一条错误,指出安全异常错误,指出

“异常详细信息:System.Security.SecurityException:该程序集不允许部分受信任的调用者。”

这让我感到困惑它作为 Visual Studio 类文件部署到网站的 bin 目录中。 然而,当我将其放入共享点解决方案时,它就崩溃了! 我尝试将

'[程序集:System.Security.AllowPartiallyTrustedCallers]'

添加到AssemblyInfo.cs,但这没有帮助。

还有其他人经历过这个或有什么建议吗?

编辑:我还应该提到,背后的代码正在尝试访问共享点列表。

I created a code behind file for a custom master page in visual studio. I hooked everything up manually; safe control and custom cas policy. Everything works great!

I then wanted to put this into a sharepoint solution using WSPBuilder for better deployment. I created WSP solution, added my class file and changed the output directory to the bin folder. I then built the solution and deployed it, making sure to change the page directives on the master page to reflect the new assembly name.

Now when I go to view the sharepoint site I get an error stating Security Exception error stating

‘Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.’

This has me stumped as it works as a visual studio class file deployed to the bin directory of the website.
However when I put this into a sharepoint solution it breaks! I tried adding

‘[assembly: System.Security.AllowPartiallyTrustedCallers]’

to the AssemblyInfo.cs but this hasn’t helped.

Anyone else experinced this or have any advice?

EDIT: I should also mention that the code behind is trying to access a sharepoint list.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

苦行僧 2024-07-30 13:28:19

您可以尝试检查是否使用完全限定的部分名称,包括程序集的正确公钥令牌和命名空间。

You might try checking that you are using the fully qualified five part name including the correct public key token and namespace for your assemblies.

岁月蹉跎了容颜 2024-07-30 13:28:19

您正在召集第三方大会吗?

我最近遇到了一种情况,我正在使用第三方程序集,但它的代码中没有 AllowPartiallyTrustedCallers 。 当我尝试使用该程序集时,它会失败。

Are you calling a third party assembly?

I ran into a situation recently that I was using a third party assembly and it did not have AllowPartiallyTrustedCallers in its code. When I tried to use the assebmly, it would fail.

书信已泛黄 2024-07-30 13:28:19

您确定该程序集已意外部署到垃圾箱而不是部署到 GAC 吗? 如果有两个程序集,GAC 中的程序集优先。

Are you sure that the assembly has been deployed to bin and no to GAC by accident? If there are two assemblies the one in GAC takes precedence.

白馒头 2024-07-30 13:28:19

您是否仍然需要包含 SafeControls 条目才能使其正常工作,例如:

<SafeControl Assembly="[FullAssembly Name]"
                     Namespace="[YourMasterPageNamespace]"
                     TypeName="*"
                     Safe="True" />

或在 WSPBuilder 配置中:

<add key="BuildSafeControls" value="True" />

Don´t you still have to include the SafeControls entry in order for it to work, like:

<SafeControl Assembly="[FullAssembly Name]"
                     Namespace="[YourMasterPageNamespace]"
                     TypeName="*"
                     Safe="True" />

or in WSPBuilder config:

<add key="BuildSafeControls" value="True" />
岁月静好 2024-07-30 13:28:19

从未见过这个..但我怀疑没有多少人在 SharePoint 中创建母版页的代码隐藏(微软也没有!)。

我不知道您要构建什么,但我可能会使用母版页上包含的服务器控件来实现它。

AllowPartiallyTrustedCallers 始终为我的服务器控件修复了该问题。

web.config 文件中的信任度设置为多少? 尝试完整。

Never seen this.. but I suspect not many people have created codebehinds to the master pages in SharePoint (Microsoft doesn't too!).

I don't know what you are trying to build but I'd probably implement it using a server control that is included on the master page.

AllowPartiallyTrustedCallers has always fixed it for my server controls.

What is the trust in your web.config file set to? Try Full.

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