[英]Publish desktop application working fine on my system but when I send setup to someone, it doesn't work
I have developed a desktop c# application with localdb
. 我已经使用localdb
开发了一个桌面c#应用程序。 While publishing the application, I have selected .net framework and localdb
as a prerequisite. 发布应用程序时,我选择了.net框架和localdb
作为先决条件。 The published setup works fine on my system but when I send the complete setup files to any other system it doesn't work. 发布的安装程序在我的系统上可以正常工作,但是当我将完整的安装程序文件发送到任何其他系统时,它将无法正常工作。
Here is my connection string 这是我的连接字符串
SqlConnection(@"Data Source=(localdb)\mssqllocaldb;AttachDbFilename=|DataDirectory|\StadiumDatabase.mdf;Integrated Security=True")
Here is what I am selecting in prerequisite 这是我在先决条件中选择的
The error that I am getting on other systems. 我在其他系统上遇到的错误。
I have gone through so many blogs and articles regarding this and none of the solutions provided is working. 我浏览了很多与此有关的博客和文章,但所提供的解决方案均无效。
It looks like you have different versions of LocalDb installed on your development machine, and the installation machine. 看来您在开发计算机和安装计算机上安装了不同版本的LocalDb。 The default instance MSSQLLocalDB
used to be named by version in older versions of LocalDb, v11.0
for example. 默认实例MSSQLLocalDB
用于通过的版本在旧版本的LocalDB的命名v11.0
的例子。 Microsoft changed that to MSSQLLocalDB
in a later version of LocalDB. Microsoft在更高版本的LocalDB中将其更改为MSSQLLocalDB
。
The fact that you say (localdb)\\mssqllocaldb
works on your machine, leads me to believe that you are using that newer version. 您说(localdb)\\mssqllocaldb
在您的计算机上工作的事实使我相信您正在使用该较新版本。 Your screenshot shows that you have selected LocalDB from SQL 2012, which uses the default instance name v11.0
. 屏幕快照显示您已从SQL 2012中选择LocalDB,该数据库使用默认实例名称v11.0
。 This means you will need a different connection string remotely vs during development. 这意味着在开发过程中您将需要一个不同的远程连接字符串。 Unfortunately, I don't know of a good way to detect the instance name to adjust the connection string. 不幸的是,我不知道检测实例名称以调整连接字符串的好方法。
Running different versions of LocalDB on your development machine, and installing a different version on the remote computer, will probably cause you a lot of headaches, like this one. 在开发计算机上运行不同版本的LocalDB,并在远程计算机上安装其他版本,可能会引起很多麻烦,就像这样。 I recommend either installing whatever localDb version you are developing against on the remote machine, or installing 2012 on your development machine, so that everyone has the same version. 我建议要么在远程计算机上安装要针对其开发的任何localDb版本,要么在开发计算机上安装2012,以便每个人都具有相同的版本。
Based on comments you made, your development machine is running Sql 2016 (db version 852). 根据您的评论,您的开发计算机正在运行Sql 2016(数据库版本852)。 You either need to install Sql 2012 on your development machine, or install 2016 as the prerequisite. 您要么需要在开发计算机上安装Sql 2012,要么必须先安装2016。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.