如何在Visual Studio调试中以管理员身份运行应用程序? [英] How to run application as administrator in debug with Visual Studio?

查看:795
本文介绍了如何在Visual Studio调试中以管理员身份运行应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序,在这里我必须具有对C驱动器根目录的读/写访问权限.我意识到我可以编译代码并以管理员身份运行可执行文件,并且它可以工作.但是我需要调试它,而且不确定如何在Visual Studio中启动该应用程序.

I have a c# application where I have to have read/write access to the root of the C drive. I realize I can compile the code and run the executable as administrator and it works. But I need to debug it and I am unsure as to how one would start the app within Visual Studio.

我尝试添加:

<requestedExecutionLevel level="asInvoker" uiAccess="true" />

出现在我的清单上,但仍然出现拒绝访问错误.

to my manifest but I still get access denied error.

这是失败的代码行:

MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(@"c:\somemapnamefile.data", System.IO.FileMode.OpenOrCreate, "somemapname", 1000);

目前,我有一个解决方案,但我想知道未来.

For now I have a work around but I'd like to know for the future.

推荐答案

只需以管理员身份运行Visual Studio即可.您从那里调试的任何程序也将以管理员身份运行.

Just run visual studio itself as an administrator. Any program you debug from there will also be run as an administrator.

这篇关于如何在Visual Studio调试中以管理员身份运行应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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