Learn how to prevent the "ClickOnce does not support the request execution level" exception from appearing in WinForms.

How to solve C# WinForms build exception: ClickOnce does not support the request execution level 'requireAdministrator.'

If you are trying to force your application to start with elevated privileges, you may know that you need to mess up with the app.manifest file and the requestedExecutionLevel node of the mentioned file. However, if you try to compile your app and this exception shows up, you need to know that the error is caused due to the ClickOnce security settings, so if you ever use the publishing wizard, or 'Publish Now', the click-once checkbox gets automatically selected and you won't never know what happened (having this checkbox checked causes the exception). But don't worry, we have the solution for this exception.

In this article, we'll explain you briefly how to prevent this exception from appearing in your WinForms application.

Solution

As first step, proceed to disable the ClickOnce security settings from your WinForms project. Open your project in Visual Studio and access the Project properties through the Project menu and then click on YourProjectName Properties:

WinForms Project Properties

When the properties dialog shows up, go to the security Tab and disable (uncheck the Enable ClickOnce security settings):

Project Disable ClickOnce

Once you uncheck this field and you try to compile again your application, the exception shouldn't appear anymore. ClickOnce is enabled whenever you click on "Publish", whether you want it to or not, so if you are using "requireAdministrator" then it appears that you cannot use ClickOnce, and therefore you cannot "Publish" your project.

Happy coding !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors