简体   繁体   English

安装程序C#Windows Form App / SDF数据库

[英]Installer c# windows form app/sdf database

I did ac# windows form app that uses a local .sdf database (SQL Server Compact Edition) but I can't create an installer for that. 我做了一个使用本地.sdf数据库(SQL Server Compact Edition)的ac#Windows窗体应用程序,但无法为此创建安装程序。

I use the setup wizard from Visual Studio but the intalled program gives me an unhandled exception error. 我使用Visual Studio中的安装向导,但安装的程序给了我一个未处理的异常错误。 I don't know if the error is the connection string or other. 我不知道错误是连接字符串还是其他字符串。

My problem is not access the .sfd database but create a setup in order to install the application in other computers. 我的问题不是访问.sfd数据库,而是创建一个安装程序以便在其他计算机上安装该应用程序。 To create an installer project I used the setup wizard project of visual studio 2010 but when I install the application using the generated setup the program does not run. 为了创建安装程序项目,我使用了Visual Studio 2010的安装向导项目,但是当我使用生成的安装程序安装应用程序时,该程序无法运行。 My problem is that I don't know how to create a setup for my application. 我的问题是我不知道如何为我的应用程序创建设置。 The connection string is "Data Source = |DataDirectory|DataBase\\yyyy.sdf" in the app.config. app.config中的连接字符串为“数据源= | DataDirectory | DataBase \\ yyyy.sdf”。 I don't have any code for the installer. 我没有安装程序的任何代码。

In order to find that out please show us your code, but at least wrap your DB methods in a try-catch block: 为了找出答案,请向我们展示您的代码,但至少将您的数据库方法包装在try-catch块中:

try
{
  // do your DB stuff here
}
catch (Exception ex)
{
  MessageBox.Show(ex.Message);
}

Without having seen your code, check that you don't hard code paths to the .sdf as an example. 在没有看到您的代码的情况下,请检查您是否未对.sdf的路径进行硬编码作为示例。 Further, are you distributing all the required dependencies for SQL Server Compact ? 此外,您是否正在分发SQL Server Compact的所有必需依赖项 Remember to not install the .sdf in the program files Folder, as it violates Window's user Access model. 请记住不要将.sdf安装在程序文件Folder中,因为它违反了Window的用户访问模型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM