Mixed mode assembly in .NET 4

醉酒当歌 提交于 2019-11-26 16:13:50

The best would probably be to recompile your class library for .NET 4.0 in Visual Studio 2010 (ie. opening up the project, converting it, and changing the target framework.)

If you can't, or won't, do that, then you can try adding the following to your app.config file for your .NET 4.0 application:

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
</startup>

ie.

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

Since your assembly is mixed-mode, it potentially can call managed code from the unmanaged machine code in the assembly. With the new in-process side-by-side CLR version support in .NET 4.0, the runtime doesn't know which CLR version needs to be provided when that happens. You have to tell it that with an app.exe.config file that should look like this:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>
Ribeiro

Another way: In VB 2010 Express you can open your project and go to the tab Compile and then Advanced Compile Options.... Select .NET Framework 2.0 from the drop-down list named Target framework (all configurations).

If you are not getting through even by specifying useLegacyV2RuntimeActivationPolicy="true", you may need to install a setup that is compatible with your OS and .NET version. You can find the same at http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki.

Before installing this setup, uninstall SQLite from installed programs. That will show errors in your code.

If it is not working even after installing compatible setup, you have to remove the reference to your previous DLL file and add a new reference to this compatible DLL file.

When you add a reference to a compatible DLL file you just have to build your project and all your code errors should have gone.

REA_ANDREW

You could try opening the old faithful project (Class Library) inside of Visual Studio 2010 and allow it to do the conversion for you.

If anyone else still run into this issue, here is my diagnosis: You are using wrong SQLite package. There are many versions of SQLite under http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

For example, if you are targeting .net 4.5 with x86 platorm you should use this file:

under Precompiled Statically-Linked Binaries for 32-bit Windows (.NET Framework 4.5)

sqlite-netFx45-static-binary-bundle-Win32-2012-1.0.106.0.zip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!