简体   繁体   中英

Deploying windows application in Visual studio 2010 Express

I have developed a windows application on C# in Visual Studio Express 2010. Now I want to deploy it.

I used publish to deploy but when I run the project it get error on the form where I have used some external files which I am using for I/O operation, read and write files.

How do I resolve this error? I am also using one folder for files.

I'm a big fan of using WiX for installers - even if you've got Visual Studio Pro with the built in MSI creation tools

http://wix.sourceforge.net/

the benefit of WiX is that you can do most anything, from the super simple to very complicated. The tool is great b/c you can get started quickly and then move up (adding dialogs, etc) as your app gets more popular.

One trick for installers - consider using VMWare/HyperV, install a test OS then take a snapshot of the OS before you install your app. IF everything works, great - you're done. However if something isnt right, roll the OS back to the pre-install snapshot, fix the bug, and try it again.

That may be due Windows 7 UAC permissions. Despite the fact that current books, msdn and even the snippets in Visual Studio teach methods of file IO, most are not correct when taking UAC into consideration.

All of your file operations should take place in UAC safe zones such as Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

You cannot read or write to files in the C:\\Program Files (x86) directories unless you have elevated your app to run with higher privileges.

If you install your application and right click the executable and select Run As Administrator and everything works the problem is UAC.

If you haven't coded around UAC limitations I highly recommend reading up on it. It will save many headaches down the road.

http://www.codeproject.com/Articles/17968/Making-Your-Application-UAC-Aware

  1. Add those external files to the project
  2. Right Click the external files in your VS Set the Build Action as Content
  3. Copy to Output directory to CopyAlways

Then try deploying

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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