unbind BindAsLegacyV2Runtime

时间:2013-05-09 20:03:40

标签: .net-4.0 .net-2.0 legacy-code

所以我们有一个应用程序启动器,可以(应该)运行在clickOnce中创建的新应用程序和使用远程逻辑类型的旧应用程序

尝试运行应用时,我收到以下消息

Cannot load assembly. Error details: System.IO.FileLoadException: Could not load 
file or assembly 'program' or one of its dependencies. Operation is not 
supported.  (Exception from HRESULT: 0x80131515) File name:'program'  
---> System.NotSupportedException: An attempt was made to load an assembly from
a network location which would have caused the assembly to be sandboxed in 
previous versions of the .NET Framework. This release of the .NET Framework does 
not enable CAS policy by default, so this load may be dangerous. If this load is 
not intended to sandbox the assembly, please enable the loadFromRemoteSources 
switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

Google搜索我发现这段代码更新了应用配置

Loading blocked and network-hosted assemblies with .NET 4

修复旧应用程序,但现在打破了较新的应用程序

然后我找到了 Setting useLegacyV2RuntimeActivationPolicy At Runtime

这个“有效”,如果我先加载一个新应用程序,没问题,那么我加载一个较旧的应用程序就可以了,但如果我去加载一个新的应用程序它就会停止工作。

因此,当我即将运行新应用时,我需要知道如何取消绑定BindAsLegacyV2Runtime。或者我需要另外一种方法?

谢谢

1 个答案:

答案 0 :(得分:0)

添加

<runtime>
     <loadFromRemoteSources enabled="true"/>
</runtime>

修复了两种类型的应用程序的问题