如何不安装SQLite让程序可以正常使用

System.Data.SQLite.dll和System.Data.SQLite.Linq.dll不必在GAC里面,关键在于Machine.config的DBProviderFactories没有正确增加SQLite相关项,不必修改Machine.config,直接修改app.config就可以。

另外很重要的一点:configSections必须在所有配置的最前面,否则会出现“配置系统未能初始化”的异常。

 

<?xml version="1.0"?>
<configuration>
<configSections>
<section name="tidcode.Data"
type="tidcode.Data.Bases.NetTiersServiceSection, tidcode.Data"
allowDefinition="MachineToApplication"
restartOnExternalChanges="true" />
</configSections>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.87.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="netTiersConnectionString" connectionString="data source=tidcode.db" />
</connectionStrings>
<tidcode.Data defaultProvider="SqlNetTiersProvider">
<providers>

<add
name="SqlNetTiersProvider"
type="tidcode.Data.GenericClient.GenericNetTiersProvider, tidcode.Data.GenericClient"
connectionStringName="netTiersConnectionString"
providerInvariantName="System.Data.SQLite"
entityFactoryType="tidcode.Entities.EntityFactory"
useEntityFactory="true"
enableEntityTracking="false"
enableMethodAuthorization="false"
useStoredProcedure="false"
/>

</providers>
</tidcode.Data>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>

你可能感兴趣的:(sqlite)