【问题标题】:Add a bindingRedirect to the web.config declaratively in SharePoint 2007在 SharePoint 2007 中以声明方式将 bindingRedirect 添加到 web.config
【发布时间】:2011-07-08 00:01:40
【问题描述】:

可以通过创建文件向 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/”内的标签?

【问题讨论】:

    标签: sharepoint sharepoint-2007 web-config declarative


    【解决方案1】:

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

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

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

    【讨论】:

    • 感谢您指出这一点。似乎没有任何地方记录在 SharePoint 2007 中的配置文件中不能使用绑定重定向。由于时间限制,我最终使用手动部署步骤来更改 web.config。下次我将研究 SPWebConfigModification。虽然我猜 SPWebConfigModification 需要从功能接收器中使用,但我不能保证代码将以具有足够权限的用户身份运行以编辑 web.config。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-04
    • 1970-01-01
    相关资源
    最近更新 更多