C# .NET 2 异常:外部组件引发异常
本文关键字:异常 组件 外部 NET | 更新日期: 2023-09-27 18:33:34
我在 c# 2 应用程序中进行了开发。一个 ASP .NET Web 服务和一个使用该 Web 服务的 WinForms 客户端。客户端分发给许多客户。对于其中一个客户,应用程序突然开始引发以下异常:
External component has thrown an exception.
at System.Diagnostics.SharedPerformanceCounter.GetCounter(String counterName, String instanceName, Boolean enableReuse, PerformanceCounterInstanceLifetime lifetime)
at System.Diagnostics.SharedPerformanceCounter..ctor(String catName, String counterName, 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 section)
at System.Net.Configuration.SettingsSectionInternal.get_Section()
at System.Net.ServicePointManager.set_Expect100Continue(Boolean value)
at #Neh.#hgh.#P0f(String[] args)
异常末尾的混淆(使用 SmartAssembly 5)函数是客户端的主要函数,
如下所示public static void Main(string[] args) {
try {
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
System.Net.ServicePointManager.Expect100Continue = false;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Globals.Settings.NoWaitPrintJobs = true;
Application.Run(new frmMain());
}
catch(Exception ex) {
HandleUnhandledException(ex);
}
}
从异常中,我知道它正在在线中断
System.Net.ServicePointManager.Expect100Continue = false;
应用程序不引用任何互操作组件,只引用其他托管 dll。它还在 shell32 中使用了本机函数.dll
[DllImport("shell32.dll")]
static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out] StringBuilder lpszPath, int nFolder, bool fCreate);
这是在从静态对象主窗体加载事件上调用的。
Globals.Settings.InitLocalFiles();
我还不知道客户的电脑规格。我认为他有Windows XP。有什么想法吗?
看起来运行客户端的用户帐户没有使用性能计数器的正确权限
请参阅"未经授权的访问例外"-"全局''.net clr 网络"
这使得网络类不使用性能计数器。