我已经用 c# 开发了 windows 窗体应用程序。我用过这个Microsoft Visual Studio 2010。现在我想生成安装包(或者可以让我把我的程序给别人的东西),但是我遇到了一些奇怪的问题。
当我使用调试模式时 - 一切正常,所以我从 MyDocuments\Visual 2010\Solution name\Project Name\bin\Debug 获取编译程序并将其交给我的妻子进行测试......但在她的计算机程序上不运行并给出此错误:
System.Data.SqlClient.SqlException: An error has occurred with the onset of the network or connect to a SQL Server server. Can not find server or it is not available. Verify that the instance name is correct and that the configuration of SQL Server allow remote connections. (Provider: SQL Network Interfaces, error: 26 - Error locating a specific server / instance)
in System.Data.ProviderBase.DbConnectionPool.GetConnection (DbConnection owningObject)
in System.Data.ProviderBase.DbConnectionFactory.GetConnection (DbConnection owningConnection)
in System.Data.ProviderBase.DbConnectionClosed.OpenConnection (DbConnection outerConnection, DbConnectionFactory connectionFactory)
in System.Data.SqlClient.SqlConnection.Open ()
in System.Data.Common.DbDataAdapter.QuietOpen (IDbConnection connection, ConnectionState & originalState)
in System.Data.Common.DbDataAdapter.FillInternal (DataSet dataset, DataTable [] DataTables, Int32 startRecord, Int32 MaxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill (DataTable [] DataTables, Int32 startRecord, Int32 MaxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill (DataTable dataTable)
in Home_Video_Catalog.HVCDBDataSetFilmsTableAdapters.FilmsTableAdapter.Fill (FilmsDataTable dataTable) in C: \ Documents and Settings \ Aru \ My Documents \ Visual Studio 2010 \ Projects \ Home Video Catalog \ Home Video Catalog \ HVCDBDataSetFilms.Designer.cs: line 868
in Home_Video_Catalog.MainWindow.MainWindow_Load (Object sender, EventArgs e) in C: \ Documents and Settings \ Aru \ My Documents \ Visual Studio 2010 \ Projects \ Home Video Catalog \ Home Video Catalog \ MainWindow.cs: line 27
in System.Windows.Forms.Form.OnLoad (EventArgs e)
in DevComponents.DotNetBar.Office2007RibbonForm.OnLoad (EventArgs e)
in System.Windows.Forms.Form.OnCreateControl ()
at System.Windows.Forms.Control.CreateControl (Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl ()
in System.Windows.Forms.Control.WmShowWindow (Message & m)
at System.Windows.Forms.Control.WndProc (Message & m)
in System.Windows.Forms.ScrollableControl.WndProc (Message & m)
in System.Windows.Forms.ContainerControl.WndProc (Message & m)
in System.Windows.Forms.Form.WmShowWindow (Message & m)
in System.Windows.Forms.Form.WndProc (Message & m)
in DevComponents.DotNetBar.Office2007RibbonForm.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)
...所以我想如果我创建安装程序项目并为我的项目创建设置就可以了...但是错误与以前的错误代码相同。
我不太明白,因为在我的项目配置文件(项目下的 app.config 和 Properties\settings.settings)中是正确的连接字符串:
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HVCDB.mdf;Integrated Security=True;User Instance=True"
同样有趣的是错误消息中的路径在我的计算机上有效(这是我的项目)
请帮我 :)