Sharepoint 2010 通过 wsp 将控件注册为安全

发布于 2024-09-26 08:04:10 字数 795 浏览 1 评论 0原文

我使用 VS2010 创建了一个“Hello World”Sharepoint 2010 解决方案。它仅包含一个功能和一个包含标签的 Web 部件。我在 VS2010 的 Web 部件的“属性”窗口中将 Web 部件注册为安全控件。

当我将解决方案部署到本地服务器时,一切都运行良好!我可以将 Web 部件添加到页面,并在 web.config 文件中将我的控件添加到 SafeControls 列表中。当我在不同的服务器上安装相同的解决方案时,我可以在可用 Web 部件列表中看到该 Web 部件,但是当我尝试将其添加到页面时,它告诉我它未注册为安全。当我检查 web.config 文件时,没有我的控件的条目。如果我手动添加一个(来自我的开发服务器的),事情就会开始工作。

现在,我想知道为什么当我安装wsp文件时控件没有注册。 wsp 内的清单包含以下行:

<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>

非常欢迎任何想法!

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.

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.

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>

Any ideas are very welcomed!

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

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

发布评论

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

评论(3

帅冕 2024-10-03 08:04:10

检查拼写错误和版本差异。

Check for typos and version differences.

怪我闹别瞎闹 2024-10-03 08:04:10

您是否激活了网络应用程序的功能?

Did you activate the feature for the web app?

生寂 2024-10-03 08:04:10

我知道迟到的答案。

我认为您的 SafeControl 标签中缺少“ Safe=”TRUE” 。

正确代码:

<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>

Late answer I know.

I think you are missing ' Safe="TRUE" ' in your SafeControl Tag.

Correct code:

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