在SharePoint 2007中以声明方式将bindingRedirect添加到web.config

时间:2011-03-03 11:34:07

标签: sharepoint sharepoint-2007 web-config declarative

可以通过创建文件来添加密钥到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 /”中的标签?

1 个答案:

答案 0 :(得分:1)

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

要注意虽然不容易 - 只需搜索SPWebConfigModification并查看结果的第一页。

作为替代方案,我必须问你为什么要这样做 - 如果这只是版本化的微小变化(即v1.1&gt; v1.2)那么也许这不是最好的方法 - 请改为file assembly versioning

相关问题