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:
When the properties dialog shows up, go to the security Tab and disable (uncheck the Enable ClickOnce security settings):
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.