How to run application as administrator in debug with Visual Studio?

c#, visual-studio

Solution

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

Problem

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. I have tried adding: ``` <requestedExecutionLevel level="asInvoker" uiAccess="true" /> ``` to my manifest but I still get access denied error. Here is the line of code that fails: ``` 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.

Original source

Related problems