通过创建包含以下内容的文件:12/ web.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/“中的标签才能添加?
发布于 2011-03-05 02:23:54
您不能在SharePoint 2007中使用配置文件在部署时添加绑定重定向(尽管在2010中可以),因此您必须使用SPWebConfigModification编写代码来完成此操作。
但要注意,这并不容易--只要在SPWebConfigModification上搜索一下,然后查看第一页的结果就行了。
作为另一种选择,我不得不问为什么你可能想要这样做-如果这只是版本控制微小的更改(即v1.1 > v1.2),那么这可能不是最好的方法-请查看file assembly versioning。
https://stackoverflow.com/questions/5180175
复制相似问题