报错 System.ComponentModel.Win32Exception:拒绝访问,如何以管理员身份调试应用程序...

本文介绍如何通过修改app.manifest文件中的requestedExecutionLevel设置,使Visual Studio中的程序能在调试时以管理员权限运行,解决权限不足的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

打开程序集的属性窗口,找到“安全性”设置,其中有一个“启用 ClickOnce 安全性设置”,勾选后再反勾选该复选框。

此时在解决方案资源管理器中,就可以找到 app.manifest 文件,勾选“启用 ClickOnce 安全性设置”是为了让VS生成这个文件,取消勾选是为了支持后面对 requestedExecutionLevel 的设置。

打开 app.manifest,将 requestedExecutionLevel 设置为 

<requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

如下图所示:

三个level的功能如下:

asInvoker:应用程序就是以当前的权限运行。

highestAvailable:应用程序以当前用户可以获得的最高权限运行。

requireAdministrator:应用程序仅以系统管理员权限运行。

我们将其改为 requireAdministrator

此时再次调试程序时,VS会提示“此任务要求应用程序具有提升的权限”,点击“使用其他凭据重新启动”即可。如果还是弹出之前“拒绝访问”的异常,可尝试重启一下VS。

此时再调试程序,就可以直接以管理员身份进行调试了

 

2025-06-21 12:21:22,899 1 ERROR Global360.Bos.AnalysisEngine.Core.AdminDbCommands: Unable to open connection for user : Exception: System.Data.SqlClient.SqlException Message: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.) Source: .Net SqlClient Data Provider Stack Trace: at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at Global360.Bos.AnalysisEngine.Core.DynamicDbCommands.OpenConnection() Nested Exception: System.ComponentModel.Win32Exception Message: The certificate chain was issued by an authority that is not trusted 解释一下这个track是什么意思
最新发布
06-23
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值