部署与SQL Server防爆preSS桌面应用程序 [英] Deploying a desktop application with SQL Server Express

查看:252
本文介绍了部署与SQL Server防爆preSS桌面应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了使用SQL Server的防爆preSS 2005数据库的C#4.0的桌面应用程序。我建立了一个安装和部署(MSI)软件包,安装应用程序和所有它的depenedencies,包括MDB数据库文件,到Program Files目录下的一个工作文件夹。

I have developed a C# 4.0 desktop application that uses a SQL Server Express 2005 database. I have built a Setup and Deployment (msi) package that installs the application and all it's depenedencies, including the mdb database file, into a working folder under the Program Files directory.

连接字符串是这样的:

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|MyDB.mdf;Database=MyDB;integrated security=true;user instance=true;

第一次数据库调用时,该数据库被连接到本地SQL Server防爆preSS实例。

The first time a database call is made, the database gets connected to the local SQL Server Express instance.

安装程序将按预期在XP的计算机,但是,当在Windows 7计算机测试一个异常被抛出的第一次数据库调用时,其中指出,有包含MDB文件的文件夹的权限不够。

The installer works as expected on XP computers, however, when tested on Windows 7 machines an exception is thrown the first time a database call is made, which states that there are insufficient permissions on the folder containing the mdb file.

之间的Windows XP和Windows 7中,Windows似乎锁定在Program Files文件子文件夹的权限。 我可以解决通过设置完全权限安装目录的问题,但是,似乎是作弊。

Between Windows XP and Windows 7, windows seems to have locked down permissions on Program Files subfolders. I can solve the problem by setting full permissions to the installation directory, but that seems like cheating.

所以我的问题是这样的: 我应该如何配置设置和部署包为这个应用程序? 我做对吗?难道我只是需要授予完全权限的应用程序目录中的所有用户?如果是这样,我怎么做到这一点的,VS2010安装和部署包? 或者我应该把MDB文件somehwere别的吗?还是我完全准备的事情的错误的方式?

So my question is this: How should I be configuring the setup and deployment package for this application? Am I doing it right? Do I just need to grant full permissions to all users on the applications directory? If so, how do I achieve this with a VS2010 setup and deployment package? Or should I place the mdb file somehwere else? Or am I totally going about things the wrong way?

推荐答案

下面是完整的解决方案,我最终实现。

Here is the complete solution I ended up implementing.

  • 在安装和部署项目,在文件系统部分,我添加了SQL Server数据库文件(MDF),以共同Application Data文件夹。这不是可选选项从[右点击进入]文件系统上的目标计算机\添加特殊文件夹菜单(出于某种原因),所以我不得不从菜单中选择自定义文件夹,然后在默认位置属性,把[ COMMONAPPDATAFOLDER] [生产企业] [产品名称]。这在通用应用程序数据文件夹,无论它可能是在目标机器上做了一个文件夹(C:\程序数据\为Win 7)。我的产品
  • 在我需要的所有用户能够完全访问此文件夹的SQL Server数据库文件,以成功地附加和正常工作,所以下一步是要更改这个文件夹的权限。
  • 在我能找到这样做的唯一方法是写一个自定义操作的安装和部署项目。这个链接给出了如何创建并添加自定义操作了良好的破败:的http://thedotnetway.blogspot.com.au/2008/10/creating-setup-project-in-vs-2008-w.html
  • 在此链接提供了一个需要投入的自定义操作覆盖安装方法code: <一href="http://stackoverflow.com/questions/8944765/c-sharp-set-directory-permissions-for-all-users-in-windows-7">C# - 设置目录权限在Windows所有用户7
  • 在我使用System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData)中的自定义操作code指定通用应用程序数据文件夹。
  • In the Setup and Deployment project, in the File System section, I added the SQL Server database file (MDF) to the Common Application Data folder. This is not one of the selectable options from the [Right Click]File System On Target Machine\Add Special Folder menu (for some reason), so I had to select Custom Folder from that menu then in the Default Location property, put "[CommonAppDataFolder][Manufacturer][ProductName]". This made a folder in the Common Application Data Folder, wherever it may be on the target machine (C:\Program Data\ for Win 7) for my product.
  • I needed all users to be able to have full access to this folder for the SQL Server database file to successfully attach and work properly, so the next step was to change permissions on this folder.
  • The only way I could find to do that was to write a Custom Action for the Setup and Deployment project. This link gives a good rundown of how to create and add a Custom Action: http://thedotnetway.blogspot.com.au/2008/10/creating-setup-project-in-vs-2008-w.html
  • This link provides the code that needs to be put into the Custom Actions overridden Install method: C# - Set Directory Permissions for All Users in Windows 7
  • I used System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) in the Custom Action code to specify the Common Application Data folder.

希望,使生活更容易为任何开发商在未来类似的要求。

Hopefully that makes life easier for any developers in the future with similar requirements.

这篇关于部署与SQL Server防爆preSS桌面应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆