我在 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。请问有什么想法吗?