UAC Enable your C# Application

I recently ran into an issue with a desktop side application I was developing that did some manipulation against some files in the program files direction. Because of the permissions assigned on that directory a person with UAC turned on couldn’t run the application and was presented with a very nasty .Net exception box.

The fix was to have the application always run in admin mode, removing the permissions issue. With some Googling I determined that all I needed to do was click the “View UAC Settings” button in the Application Properties. But wait, that is VB only apparently.

To get this working what I had to do was add the Application Manifest File from the “Add New Item” dialog.

image 

image

Then once it was added to the solution I opened it up and changed one line from:

image

to

image

I then re-compiled and it was good to go, the little shield appeared on the executable image without any other work required. It too me a few searches before I found anyone that mentioned C# not having the "View UAC Settings” button and you had to add the file manually. It’s a shame that MS is still having VB.Net so drastically different from C# from a Visual Studio UI side in things like that. Apparently they are under the distinct impression that we need to spend more time on ‘plumbing’ and not working on our business logic.

About: Shawn Jackson

I’ve spent the last 18 years in the world of Information Technology on both the IT and Development sides of the aisle. I’m currently a Software Engineer for Paylocity. In addition to working at Paylocity, I’m also the Founder of Resgrid, a cloud services company dedicated to providing logistics and management solutions to first responder organizations, volunteer and career fire departments, EMS, ambulance services, search and rescue, public safety, HAZMAT and others.