Sharepoint 2010 register control as safe through wsp

佐手、 提交于 2019-12-10 10:01:55

问题


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!


回答1:


Check for typos and version differences.




回答2:


Did you activate the feature for the web app?




回答3:


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>


来源:https://stackoverflow.com/questions/3891038/sharepoint-2010-register-control-as-safe-through-wsp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!