The "Go" Sqlite mixed-mode assembly is generated for the "v2.0.50727" version of the runtime and cannot be loaded in the 4.0 runtime without additional information configured ...

Source: Internet
Author: User
Tags sqlite sqlite database

Development environment: Vs2010+.net Framework 4.0+ System.Data.SQLite.DLL (2.0)
Today in the SQLite database test, a running program in a method called the Times out an exception

Mixed-mode assemblies are generated for the "v2.0.50727" version of the runtime and cannot be loaded in the 4.0 runtime without additional information being configured

Its call method is from the SQLite database to get the original used database connection, then did not notice, is ready to set breakpoints and then single-step debugging, the result is a breakpoint can not enter the method body, and then carefully looked at the method body when found a problem, Is the existing System.Data.Sqlite this data access provider is for. NET2.0 Environment Development (the latest version is 1.0.66.0, released on April 18, 2010), and the current official has not given the latest. NET4 data access support.

Since this problem, it must be a Google search solution, after all, Microsoft can not because of the upgrade to. The NET4.0 program cannot access the. NET2.0 Assembly Bar. Later on in the famous stackoverflow.com found the solution, is to add a configuration section in App. Config:startup

<startupuseLegacyV2RuntimeActivationPolicy="true">

<supportedRuntimeversion="v4.0"/>

</startup>

The meaning of this section of the configuration is (refer to from MSDN, specific address: http://msdn.microsoft.com/zh-cn/library/bbx34a2h.aspx):

You enable the. NET Framework version 2.0 runtime activation policy, which is loaded by using the latest supported runtime for all assemblies.

Note: Due to the nature of the config configuration file, if the configsections node exists in the config configuration file, you must put configsections in one, otherwise an exception will be thrown: configuration system failed to initialize

In the original. net2.0,.net3.5, due to the nature of the operating environment of the program or. NET2.0, and to the. NET4.0 because the entire assembly version is updated, the previously used. NET2.0 assembly with the. NET4.0 Assembly continues to be screwed interop when the above mentioned compatibility issues occur.

With MSDN, we know that the useLegacyV2RuntimeActivationPolicy property in the Startup configuration section is new in. NET4.0, and the default is False, which means:

Using the default. NET Framework 4 activation policy, the activation policy will load the. NET Framework 4 assemblies created by using the common language runtime (CLR) version 4, as well as earlier versions of the CLR by using a supported version of the highest CLR versions below version 4 The Created Assembly

Now if the program is in. You must set the useLegacyV2RuntimeActivationPolicy to True when you want to use the. NET2.0 and. NET3.5 programs in the NET4.0 environment, and also note that you need to add supportedruntime configuration in the bytes of the Startup configuration section section, and is specified as "v4.0", which indicates use. NET4.0 the runtime to run the program.

For more startup and its children, you can view MSDN:

Startup:http://msdn.microsoft.com/zh-cn/library/bbx34a2h.aspx

Supportedruntime:http://msdn.microsoft.com/zh-cn/library/w4atty68.aspx

The "Go" Sqlite mixed-mode assembly is generated for the "v2.0.50727" version of the runtime and cannot be loaded in the 4.0 runtime without additional information configured ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.