在 Visual Studio 2010 Express 中部署 Windows 应用程序
我在 Visual Studio Express 2010 中用 C# 开发了一个 Windows 应用程序。现在我想部署它。
我使用发布来部署,但是当我运行该项目时,它在表单上出现错误,其中我使用了一些用于 I/O 操作、读取和写入文件的外部文件。
我该如何解决这个错误?我还使用一个文件夹来存放文件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我非常喜欢使用 WiX 进行安装 - 即使您拥有带有内置 MSI 创建工具的 Visual Studio Pro
http://wix.sourceforge.net/
WiX 的好处是您可以做几乎任何事情,从超级简单到非常复杂。该工具很棒,因为您可以快速入门,然后随着您的应用程序变得更受欢迎而升级(添加对话框等)。
安装人员的一个技巧 - 考虑使用 VMWare/HyperV,安装测试操作系统,然后在安装应用程序之前拍摄操作系统的快照。如果一切正常,那就太好了 - 你就完成了。但是,如果出现问题,请将操作系统回滚到安装前快照,修复错误,然后重试。
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.
然后尝试部署
Then try deploying
这可能是由于 Windows 7 UAC 权限所致。尽管当前的书籍、msdn 甚至 Visual Studio 中的代码片段都教授了文件 IO 的方法,但在考虑 UAC 时,大多数都是不正确的。
所有文件操作都应在 UAC 安全区域中进行,例如
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
您无法读取或写入 C:\Program Files (x86) 目录中的文件,除非您已提升应用程序以更高的权限运行。
如果您安装应用程序并右键单击可执行文件并选择以管理员身份运行并且一切正常,则问题是 UAC。
如果您还没有围绕 UAC 限制进行编码,我强烈建议您阅读它。这将避免以后出现许多令人头疼的问题。
http://www.codeproject.com/Articles/17968/Making -您的应用程序 UAC 感知
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