Deploy Windows Application without installing Sqlite .net provider
I am using SubSonic 3 with SQLite 3 for a Windows Application. Installing the .NET provider for SQLite (System.Data.SQLite) was mandatory for me while programming the application, my requirement for deploying the application is, I just want to create one installable and skip the portion for installing .NET provider for SQLite on client machine.
I have added the references of Sy开发者_如何学Gostem.Data.SQLite into GAC(in the Setup Project) but that won't work because while running the application it says
System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
I am sure there is a workaround for this, it shouldn't be necessary to install the .Net Framework provider for SQLite on the client machine.
-mmcmedic
In addition to copying the DB driver .dll with your application, you may also need to register the DbProviderFactory.
Normally the installer would also register the data provider name in the .NET machine.config
file, so that ADO.NET can translate the provider name string to the actual assembly name. You can add this directly to your app.config file instead. I don't have a SQLite example, but I have this in my app.config for MySql:
<configuration>
...
<system.data>
<DbProviderFactories>
<clear/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
</DbProviderFactories>
</system.data>
...
</configuration>
You can get the correct configuration element for SQLite out of your machine.config on a computer that has the driver properly installed by looking in:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
Also note that I include a "clear" element in my config above, because if the DbProviderFactory had already been registered by machine.config, it would throw an exception. So I clear them all and just re-add the ones my application needs. You can omit the "clear" element if you are positive that the machines will not have the DB driver installed.
You just need to deploy the System.Data.SQLite.dll
along with your application. Just put it in the same fodler as your executable and .NET should find it automatically. You could also try to ILMerge it into your executable.
精彩评论