我正在用户 Guest 下测试我的应用程序。它因以下错误而崩溃。
'UnauthorizedAccessException' - 'Global.net clr 网络'
现在,我知道我可以编辑计算机上的安全策略,以允许信任来宾下运行的 CLR 代码,但在商业应用程序上应该做什么?
(签名,并添加CAS属性?)
我目前正在阅读整个安全部分,但我时间紧迫,因此任何正确方向的指示都将不胜感激。
编辑:我已将问题追溯到使用 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase 类。如果包含此内容,则会出现错误。
我正在寻找添加到清单或其他方式的内容,以便在安装/运行应用程序时,它会请求适当的权限。我不想要求用户亲自调用 caspol 或其他一些工具。
环境详情:
- 应用程序正在使用.NET 3.0
- 操作系统是Vista
以下是这些内容的相关堆栈跟踪:
Unhandled Exception: System.UnauthorizedAccessException: Access to the path 'Glo
bal\.net clr networking' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Threading.Mutex.<>c__DisplayClass3.<.ctor>b__0(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCl
eanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean&
createdNew, MutexSecurity mutexSecurity)
at System.Diagnostics.SharedUtils.EnterMutexWithoutGlobal(String mutexName, M
utex& mutex)
at System.Diagnostics.SharedPerformanceCounter.Verify(CategoryEntry* currentC
ategoryPointer)
at System.Diagnostics.SharedPerformanceCounter.FindCategory(CategoryEntry** r
eturnCategoryPointerReference)
at System.Diagnostics.SharedPerformanceCounter.GetCounter(String counterName,
String instanceName, Boolean enableReuse, PerformanceCounterInstanceLifetime li
fetime)
at System.Diagnostics.SharedPerformanceCounter..ctor(String catName, String c
ounterName, String instanceName, PerformanceCounterInstanceLifetime lifetime)
at System.Diagnostics.PerformanceCounter.Initialize()
at System.Diagnostics.PerformanceCounter.set_RawValue(Int64 value)
at System.Net.NetworkingPerfCounters.Initialize()
at System.Net.Configuration.SettingsSectionInternal..ctor(SettingsSection sec
tion)
at System.Net.Configuration.SettingsSectionInternal.get_Section()
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.Sockets.Socket.get_SupportsIPv4()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.get_
HostName()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Regi
sterChannel(Boolean SecureChannel)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(
String[] commandLine)