简体   繁体   English

Inno安装安装

[英]Inno setup installation

I made a WPF app which I can install on other computers, everything works fine except for database access. 我制作了一个WPF应用程序,可以将其安装在其他计算机上,除了可以访问数据库之外,其他所有功能都可以正常运行。 Currently, I have a sqlite database on my computer and the connection string for this database is specific to my computer. 当前,我的计算机上有一个sqlite数据库,该数据库的连接字符串特定于我的计算机。

I am able to run my application on other computers if I manually create the same directory structure where the database is stored. 如果我手动创建存储数据库的相同目录结构,则可以在其他计算机上运行我的应用程序。

How can I make an installer which allows me to choose the destination of the database? 我如何制作一个允许我选择数据库目的地的安装程序?

How can I get the new connection string for this new database? 如何获得此新数据库的新连接字符串?

Thanks in advance ! 提前致谢 !

I assume that you hardcoded your connection string into your application - instead, you could save your connection string in an Application Configuration File . 我假设您已将连接字符串硬编码到应用程序中,而是可以将连接字符串保存在“ 应用程序配置文件”中 This is essentially an XML file that you can use to store certain values for your application and that you can change even after the app is deployed without recompiling it. 本质上,这是一个XML文件,您可以使用它存储应用程序的某些值,并且即使在部署应用程序后也无需重新编译即可更改它。

At the beginning of your application, you can easily use the ConfigurationManager class to load a connection string from the App.config file like this: 在应用程序的开始,您可以轻松地使用ConfigurationManager类从App.config文件中加载连接字符串,如下所示:

var connectionString = ConfigurationManager.ConnectionStrings["myDBConnectionString"];

You can then pass this connection string to your objects that depend on them. 然后,您可以将此连接字符串传递给依赖它们的对象。 Please note that if you're using certain Object-Relational-Mappers like Entity Framework and NHibernate that you might not even have to retrieve the connection string manually (eg Entity Framework retrieves a connection string from App.config automatically if the name is the same as the class that implements DBContext ). 请注意,如果您正在使用某些对象关系映射器(例如Entity Framework和NHibernate),则甚至不必手动检索连接字符串(例如,如果名称相同,则Entity Framework会自动从App.config中检索连接字符串)作为实现DBContext的类)。

If you have any further questions, please feel free to ask. 如果您还有其他疑问,请随时提问。

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

相关问题 在安装过程中使用Inno Setup设置应用程序语言的推荐方法 - Recommended way to setup application language with Inno Setup during installation 在inno setup Compiler创建设置后,我的程序在目录(app目录内)中保存文件时停止了吗? - My program stop when it saves files on the directory (inside the app directory) after creating the setup by inno setup Compiler? WPF安装程序安装路径出现问题 - Problem with WPF Setup Program Installation Path Webview 运行时设置,同时 wpf 应用程序安装 - Webview runtime setup while wpf app installation 应用程序在 Visual Studio 中编译良好,但从 Inno Setup 5 中创建的安装程序启动时崩溃 - App compiles fine in Visual Studio but crashes when launch from the Installer created in Inno Setup 5 SetupIconFile 上的 Inno Setup 错误 - 该进程无法访问该文件,因为它正被其他进程使用 - Inno Setup error on SetupIconFile - The process cannot access the file because it is being used by other process Visual Studio 2010 安装项目 - 对现有安装的小更新 - Visual Studio 2010 Setup Project - Minor update to an existing installation .MSI setup package 安装问题,安装前询问 .NET Desktop Runtime - .MSI setup package installation issue, asks .NET Desktop Runtime before installation WPF安装 - WPF installation 设置应用 - Setup application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM