1

可以通过创建文件将密钥添加到 web.config:12/CONFIG/webconfig.name.xml(参见http://msdn.microsoft.com/en-us/library/ee413929.aspx) 内容:

<actions>
<add path="configuration/SharePoint/SafeControls">
    <SafeControl
        Assembly="CustomWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=123456789abcdefgABC"
        Namespace="CustomWebPart"
        TypeName="*"
        Safe="True" />
</add>
<add path="configuration/runtime/assemblyBinding">
  <dependentAssembly>
     <assemblyIdentity name="CustomWebPart" publicKeyToken="123456789abcdefgABC" culture="neutral" />
     <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
</actions>

这对于添加安全控件非常有用,但它似乎不适用于程序集重定向。有谁知道为什么这不起作用?是不是只能添加“configuration/SharePoint/”内的标签?

4

1 回答 1

1

您无法使用 SharePoint 2007 中的配置文件在部署时添加绑定重定向(尽管您可以在 2010 年),因此您必须使用SPWebConfigModification编写代码来执行此操作。

请注意,尽管它并不容易 - 只需搜索 SPWebConfigModification 并查看结果的第一页。

作为替代方案,我不得不问你为什么要这样做 - 如果这只是版本控制的微小更改(即 v1.1 > v1.2)那么也许这不是最好的方法 - 检查文件汇编版本控制

于 2011-03-04T18:23:53.603 回答