1. 程式人生 > >system.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727'...問題解決方案

system.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727'...問題解決方案

system.IO.FileLoadException: Mixed mode assembly is built against version ‘v2.0.50727’問題解決方案

載入了大恆影象的GxIAPINET.dll 檔案後,出現瞭如下錯誤提示

system.IO.FileLoadException: 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檔案
這裡寫圖片描述
我的開啟後是如下程式碼:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>
</configuration>

在startup後面新增一句話 useLegacyV2RuntimeActivationPolicy=”true” :

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

然後儲存,然後先清除再重新編譯,問題解決。
這裡寫圖片描述