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

问题描述 投票:3回答:3

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

当我将我的解决方案部署到我的本地服务器时,一切都很好!我可以将webpart添加到页面,并在web.config文件中将我的控件添加到SafeControls列表中。当我在不同的服务器上安装相同的解决方案时,我可以在可用的webpart列表中看到webpart,但是当我尝试将其添加到页面时,它告诉我它没有注册为安全。当我检查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>

任何想法都非常欢迎!

sharepoint-2010 web-parts wsp safecontrols
3个回答
0
投票

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


0
投票

您是否为网络应用激活了该功能?


0
投票

我知道的答案很晚。

我认为你的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>
© www.soinside.com 2019 - 2024. All rights reserved.