Sharepoint 2010 通过 wsp 将控制注册为安全 [英] Sharepoint 2010 register control as safe through wsp
问题描述
我使用 VS2010 创建了一个Hello World"Sharepoint 2010 解决方案.它只包含一个功能和一个包含标签的 webpart.我在 VS2010 的 webpart 的属性"窗口中将 webpart 注册为安全控件.
I created a "Hello World" Sharepoint 2010 solution using VS2010. It contains just a feature, and a webpart containing a label. I registered the webpart as a safe control in the "Properties" window of the webpart, in VS2010.
当我将解决方案部署到本地服务器时,一切正常!我可以将 webpart 添加到页面,并且在 web.config 文件中,我的控件被添加到 SafeControls 列表中.当我在不同的服务器上安装相同的解决方案时,我可以在可用 webpart 列表中看到 webpart,但是当我尝试将它添加到页面时,它告诉我它没有注册为安全.当我检查 web.config 文件时,我的控件没有条目.如果我手动添加一个(来自我的开发服务器的一个),事情就会开始工作.
When I deploy my solution to my local server, everything works great! I can add the webpart to a page, and in the web.config file my control is added to the SafeControls list. When I install the same solution on a different server, I can see the webpart in the list of available webparts, but when I try to add it to the page, it tells me that it's not registered as safe. When I check the web.config file, there is no entry for my control. If I add one manually (the one from my dev server), things start to work.
现在,我想知道为什么我安装 wsp 文件时没有注册控件.wsp 内的清单包含以下行:
Now, I wonder why the control is not registered when I install the wsp file. The manifest inside the wsp contains this line:
<Assemblies>
<Assembly Location="abc.TestWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="abc.TestWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e262c75e6f6e8440" Namespace="abc.TestWebPart.VisualWebPart1" TypeName="*" />
</SafeControls>
</Assembly>
非常欢迎任何想法!
推荐答案
我知道迟到的答案.
我认为您的 SafeControl 标签中缺少Safe="TRUE"".
I think you are missing ' Safe="TRUE" ' in your SafeControl Tag.
正确的代码:
<Assemblies>
<Assembly Location="abc.TestWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl
Assembly="abc.TestWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e262c75e6f6e8440"
Namespace="abc.TestWebPart.VisualWebPart1"
TypeName="*"
Safe="TRUE"
/>
</SafeControls>
</Assembly>
</Assemblies>
这篇关于Sharepoint 2010 通过 wsp 将控制注册为安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!