The use of SQLite in vs2010 and the problems that arise

Source: Internet
Author: User
Tags sqlite

Previously only used VS2008 call SQLite, today with VS2010 call SQLite has a problem, originally wanted to load in the reference SQLite two dynamic connection files can directly invoke its connection object. But when called, the "mixed-mode assembly is for ..." error message that the program cannot run.

In the beginning, I did not use the connection of SQLite, just call me on the connection database of a package class method, how can not run into my method body, then did not notice too much, set a lot of breakpoints, and then even the form of the method is not carried out, until the back of the package inside, A single SQLite connection was written, and the error described at the beginning of the article was called when the connection was made.

Read the following version of SQLite, the initial problem is that the existing System.Data.Sqlite this data access provider is for. NET2.0 Environment Development (the latest version is 1.0.66.0, released April 18, 2010), At present, the official has not given the latest. NET4 data access support.
Search the Internet, find a solution, is to add a more configuration section in App. Config: Startup

 <   startup  uselegacyv2runtimeactivationpolicy  = "true"  >  <   supportedruntime  version  = "v4.0"  />  <  /startup  >  


       This section of the configuration means (refer to from MSDN, Address:/HTTP/ msdn.microsoft.com/zh-cn/library/bbx34a2h.aspx):
Enable  .NET Framework 2.0  version   run-time activation policy, This is done by using the latest supported runtime to load 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: The 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.
      through MSDN, we can know that The useLegacyV2RuntimeActivationPolicy property in the Startup configuration section is new in. NET4.0, and the default is False, which means:
uses the default  .net framework  4  activation policy that will load  .NET Framework 4  by using the common language runtime   (CLR)   version  4  The assemblies that were created, and the earlier versions of  CLR , were created by using the supported versions of the highest  CLR  versions below  4 .   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.

Transferred from: http://blog.csdn.net/xingxing513234072/article/details/16980305

The use of SQLite in vs2010 and the problems that arise

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.