问题描述
相关问题:
这是我的App.config文件的样子:
This is how my App.config file looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="DocumentsDBEntities" connectionString="metadata=res://*/Documents.csdl|res://*/Documents.ssdl|res://*/Documents.msl;provider=System.Data.SQLite;provider connection string="data source=C:\Users\Sergio.Tapia\Desktop\DocumentScannerDanyly\DocumentScannerDanyly\DocumentsDB.sqlite"" providerName="System.Data.EntityClient" />
</connectionStrings>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
<appSettings>
<add key="Username" value="administrador"/>
<add key="Password" value="123456"/>
</appSettings>
</configuration>
在我的开发机器上运行这个工具,但是当部署到另一台计算机时,我收到一个数据提供程序错误。 (见上面的相关问题)。
Running this on my dev machine works, but when deploying to another computer, I get an Data Provider error. (see related question above).
建议的解决方案是将其添加到App.config文件中:
The suggested solution was to add this to the App.config file:
<system.data>
<DbProviderFactories>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
</DbProviderFactories>
</system.data>
当我将其添加到App.config文件中时,在Visual中启动应用程序时会收到此错误Studio 2010:
When I add that to the App.config file, I get this error when launching the application in Visual Studio 2010:
关于这个错误的任何建议?另外,由于.sqlite文件的位置与安装位置是否相关,所以我必须将AppConfig文件中的connectionString更改为更动态的?
Any suggestion on what this error is? Also, since the location of the .sqlite file is relative to where it is installed, do I have to change the connectionString in the AppConfig file to something more dynamic?
谢谢帮助。
编辑:
当我将其添加到配置根据某人的建议,我收到一个错误:
When I add this to the config as suggested by someone here, I get an error:
<system.data>
<DbProviderFactories>
<clear />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
</DbProviderFactories>
</system.data>
推荐答案
问题很可能是硬编码到桌面的路径在你的连接字符串中:
The problem is most likely that you hard code a path to your desktop in your connection string:
C:\Users\Sergio.Tapia\Desktop\DocumentScannerDanyly\DocumentScannerDanyly\DocumentsDB.sql
除非该文件与另一台机器上的完全相同的位置存在,否则有可能不能工作
Unless this file is present with the exact same location on the other machine, chances iare it won't work
这篇关于将配置添加到App.config文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!