C # connection SQLite appears:
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. Solutions for
C # Connect SQLite database code:
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Data.SQLite;6 usingSystem.Drawing;7 usingSystem.Linq;8 usingSystem.Text;9 usingSystem.Threading.Tasks;Ten usingSystem.Windows.Forms; One A namespaceT_w_sqlite - { - Public Partial classForm1:form the { - Public Staticsqliteconnection sqlconn; - Public Static stringConnectionString ="Data source=e://test.db3; Pooling=true; Failifmissing=true";//Store A common database connection string - + Public StaticString startsqlconn () - { +Sqlconn =Newsqliteconnection (ConnectionString); A Try at { - Sqlconn.open (); - } - Catch - { -Sqlconn =NULL; in } - return "You Test success!"; to } + PublicForm1 () - { the InitializeComponent ();
* Lable.text = startsqlconn (); $ Panax Notoginseng }
Workaround:
Solution find the app. Config file
Under the configuration node of App. Config, add:
The original is:
1 <?xml version="1.0" encoding="utf-8" ?> 2 <configuration>3 4 <supportedruntime version="v4.0 " sku=". netframework,version=v4.5" />5 </startup>6 </ Configuration>
Modified to:
1<?xml version="1.0"encoding="Utf-8"?>2<configuration>3<startup uselegacyv2runtimeactivationpolicy="true">4<supportedruntime version="v4.0"sku=". netframework,version=v4.5"/>5</startup>6</configuration>
Can solve the above problems.
by Hruinger.
C # Connection SQLite appears: 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. Solutions for