Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8129745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:25:21+00:00 2026-06-06T08:25:21+00:00

I have developed a C# 4.0 desktop application that uses a SQL Server Express

  • 0

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.

The connection string is like this:

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

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

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.

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.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:25:26+00:00Added an answer on June 6, 2026 at 8:25 am

    Here is the complete solution I ended up implementing.

    • 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have VS 2008 and SQL Server 2005 Developer edition installed on my desktop.
I have developed a desktop database application. But the interface is not rich. So
I am currently working on a VB.NET desktop application that uses .mdb (Access) database
I have developed a desktop application. Now in that app I want to add
We have a desktop client application developed in Swing. This application interacts with backend
I have desktop application developed in C#. The VM Size used by application is
I have developed a desktop application (.NET 2.0) and it needs to get some
We have developed a Web Application using grails, groovy and oracle as database with
I have developed a REST based server in java for Android devices and Desktop
I am developing a WPF desktop app that uses Entity Framework 4 and SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.