在程序中加入MANIFEST资源文件
首先打开Vs工程,看在Properties下是否有app.manifest这个文件;

如没有,右击工程在菜单中选择“Properties”,

选中"Security",在界面中勾选"启用ClickOnce 安全设置"后,在Properties下就有自动生成app.manifest文件。
打开app.manifest文件,找到如下代码:
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
将其修改为:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
然后在"Security"中再勾去"Enable ClickOnce Security Settings"后,重新编译就可以了。