System.IO.FileLoadException was unhandled解决方法

winform程序,framework4.0 运行程序 报错

错误如下:

System.IO.FileLoadException was unhandled
Message=Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

解决 方法

在app.config的startup节点添加属性: useLegacyV2RuntimeActivationPolicy="true"

最终像这样

<?xml version="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
</configuration>

问题解决.

原文地址:https://www.cnblogs.com/lost0/p/1801643.html