[Last Call] Learn how to a build a cloud-first strategyRegister Now


Questions about deploying my .Net application.

Posted on 2014-07-11
Medium Priority
Last Modified: 2014-07-17
Experts, I am getting ready to deploy my first .Net application. I have a question. Do I have to include with the application my .Net controls like I used to have to do with my activex controls in VB6.

Do I put my controls in "System32/SysWOW64"?
Do I put my controls in "AppData\Roaming\MyApplication"?
Does my .exe still go in environ("ProgramFiles")?
Do I put my database, EULA and other supporting files in "AppData\Roaming\MyApplication"?
Question by:Basicfarmer
  • 7
  • 5
LVL 40
ID: 40191425
You do not need to distribute the controls if you have used only the controls that come with .NET. Since the users need to install the framework before they can use your application, they already have all these controls.

The condition is different however if you use external controls, such as controls from a third party vendor or controls that you developed yourself outside of you application. If you distribute third party controls, look at their documentation to know where they are expected to be installed. If you do not have that information or are distributing your own custom controls, then the best place to store them in .NET is usually in the same directory as the application.

The .exe can go in different places, depending whether the application is 32-bit or 64-bit, and whether it is installed on a 32-bit or 64-bit computer, and depending on how you distribute it (standard installer package, custom installer, ClickOnce). For instance, on a 64-bit computer, 32-bit applications should install under Program Files (x86). If you use a standard installer package, it takes care of that for you. You will find a tool to create one under Other Project Types...Setup and Deployment in the window that you use to create a new project.

Accompanying files that are read-only such as the EULA can be installed in the same directory as the application. For the files that are read-write, the standard is User\AppData\MyCompany\MyApplication. But these are the standards. There are alternatives depending on what the file does and whether it will be shared or not by all the users on the same computer.

Author Comment

ID: 40202754
James, is ProgramData for windows 7 where i would want to put all of my read/write stuff if all users are to access the application?
LVL 40

Accepted Solution

Jacques Bourgeois (James Burger) earned 2000 total points
ID: 40203074
From a .NET application, not matter the version of Windows, Program Data is read-only for users who are not administrator. So you can put executables and dlls in there, files that need only to be read, but not files that need to be written to.

Files that needed to be written to are typically stored in 2 places.

If this is a file that the user creates himself, usually with a Save and/or Save As option in the application, then the place to store the file is in Documents (My Documents) by default, but let the user choose to store it somewhere else if he wants to.

However, if the file is not created by the user and is use internally by the application, then the recommended place is to put it in Users\AppData\<YourCompany>\<ApplicationName>.

Since Documents and Users can take different names depending on the OS, the user and the culture, you cannot hardcode them in your application. You need to retrieve them with the following calls.

If you want each user to have its own set of files:

If you want all your users to be able to write to the same files instead of having individual copies, then you would use the following:
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Closing Comment

ID: 40203091
Thanks for the great insight...

Author Comment

ID: 40203136
James, I just looked at this and Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)  = "C:\ProgramData". I thought this was read only?

My app uses a database that will be written to, I need all users on the PC to be able to access it.

Author Comment

ID: 40203141
I also have some xml files that will be written to.
LVL 40
ID: 40203175
Simply try the following, and you will see that you can write to ProgramData:

            Dim folder As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
            Dim str As New IO.StreamWriter(Path.Combine(folder, "test.txt"))
            str.Write("This is a test 34")

And if you want, right click on the folder in Windows Explorer, go in the Properties...Security...Advanced and you will see that the Users of the computer have Write access to the folder.

Author Comment

ID: 40203193
What does "Special" mean? It doesn't say write.
Screen Shot
LVL 40
ID: 40203238
Ooops. In Windows 8 it shows as Write instead of Special. Special shows only on the previous screen.

There are 2 types of security in the file system.

The standard security is the basic Windows security, that enables you to write in Program Files for instance.

.NET came in while Windows had been around a long time. Microsoft wanted to have a different set of file security options. They closed down writing to Program Files for non administrator, but opened up Program Data. They could not change the standard security however, because it would break older applications.

I suppose that Special reflects the framework having that special Write permission that is usually not there.

Author Comment

ID: 40203245
So you are saying that I should be ok deploying my files into ProgramData\MyCompany\MyApp?
LVL 40
ID: 40203272

But as always, to make sure, perform some tests before deployment.

You should always test the application in an environment that is similar to the one that the users will be working in.

I have a second user on my development computer that is not administrator and under whose account I very often test my application during development to make sure that I get the SecurityExceptions as soon as possible.

You should also deploy and test the application on another computer from time to time during deployment, so as to maker sure that you have everything that is needed. A computer that has nothing extra installed (specially not Visual Studio) except the prerequisites for the application. Before I was set up with a virtual testing environment, I used to keep my last computer for that purpose, and reinstalled Windows regularly on it in order to have a clean slate for my tests.

Author Comment

ID: 40203280
Thanks James...

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question