带有firebird数据库的c#express构建解决方案在运行时出错

带有firebird数据库的c#express构建解决方案在运行时出错,c#,error-handling,installation,exe,firebird2.5,C#,Error Handling,Installation,Exe,Firebird2.5,我一直在尝试用c#express创建我的应用程序的exe文件。我的问题是,当我从发布版编译后运行application.exe时,它会显示一个错误 System.ArgumentException: An invalid connection string argument has been supplied or a required connection string argument has not been supplied. at FirebirdSql.Data.FirebirdCl

我一直在尝试用c#express创建我的应用程序的exe文件。我的问题是,当我从发布版编译后运行application.exe时,它会显示一个错误

System.ArgumentException: An invalid connection string argument has been supplied or a required connection string argument has not been supplied.
at FirebirdSql.Data.FirebirdClient.FbConnectionString.Validate()
at FirebirdSql.Data.FirebirdClient.FbConnection.set_ConnectionString(String value)
at FirebirdSql.Data.FirebirdClient.FbConnection..ctor(String connectionString)
at Mis_Service.Loginfrm.btnLogin_Click(Object sender, EventArgs e) in d:\c sharp projects\samples\Mis-Service\Mis-Service\Loginfrm.cs:line 31
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
我认为只有在连接到数据库firebird时才会发生错误。我使用的参考资料如下

using FirebirdSql.Data.FirebirdClient;
当我尝试使用c#express的开始按钮运行程序时,代码运行良好。有什么我错过的吗?我想在exe中创建我的应用程序,以便使用第三方软件创建安装程序

这是我在app.config中的代码

<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
  <add key="ProviderName" value="MSDASQL.1"/>
  <add key="SecurityInfo" value="False"/>
  <add key="Driver" value="Firebird/InterBase(r) driver"/>
  <add key="UserID" value="sysdba"/>
  <add key="Password" value="masterkey"/>
  <add key="Database" value="D:\\database\\DB_GENERAL.FDB"/>
  <add key="DataSource" value="localhost"/>
    </appSettings>  
</configuration>

我找到了解决我问题的办法。奇怪的是,它现在正在发挥作用。这就是我所做的

  • 我根据Ojay发布的内容更改了连接字符串
  • 我已将app.config文件复制到我的发布文件夹中
  • 奇怪的是,当我试图构建exe时,我的防病毒软件(norton)阻止了我的进程,所以我暂时禁用了防病毒软件

  • 你的连接字符串是什么,你是如何提供的?发布版本在app.config文件中有所有这些内容,它可以从运行它的地方访问这些内容。i、 它们不仅存在于调试配置文件中,或者您不只是将release.exe复制到其他地方,而没有它的配置文件?。您是否也能够显示“组装”连接字符串的代码?连接字符串看起来像IBMODBC连接驱动程序。但是您通过使用FirebirdSql.data.FirebirdClient包括Firebird ADO.NET数据提供程序;我会有一个更像User=SYSDBA的连接字符串;密码=主密钥;数据库=SampleDatabase.fdb;DataSource=localhost;端口=3050;方言=3;字符集=无;角色=;连接寿命=15;池=真;最小池大小=0;MaxPoolSize=50;数据包大小=8192;服务器类型=0;这样更合适。您是否初始化FBConnection对象?好的,我将尝试使用该连接字符串,尽管在调试模式下生成时我的代码工作正常。并且将字符串串联以生成连接字符串不是很好的做法,请使用ConnectionStringBuilder,在本例中为FbConnectionStringBuilder
    conProvider = ConfigurationManager.AppSettings["ProviderName"]; // sample on how i call app.config to string
    conString = "Provider=" + conProvider + ";" +
                "Persist Security Info=" + conSecurityInfo + ";" +
                "Driver=" + conDriver + ";" +
                "User ID=" + conUserID + ";" +
                "Password=" + conPassword + ";" +
                "Database=" + conDatabase + ";" +
                "DataSource=" + conDataSource + ";" +
                "Charset=NONE;";