2012-05-09 96 views
0

我已經在c#2應用程序中開發了。一個ASP .NET Web服務和一個使用Web服務的WinForms客戶端。客戶分發給許多客戶。對於這些客戶之一,突然啓動應用程序拋出以下異常:C#.NET 2異常:外部組件拋出異常

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); 
    } 
} 

從例外,我明白,這是打破在行

應用程序不引用任何互操作組件,只是其他管理dll文件。它還使用shell32.dll中的本地函數

[DllImport("shell32.dll")] 
static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out] StringBuilder lpszPath, int nFolder, bool fCreate); 

正在主靜態對象的主表單加載事件上調用該函數。

Globals.Settings.InitLocalFiles(); 

我不知道客戶的電腦規格了。我認爲他有Windows XP。 有什麼想法嗎?

+1

在編寫異常時* * end *處的函數不是導致異常的原因; 'System.Diagnostics.SharedPerformanceCounter.GetCounter'是; [聽起來像是權限問題](http://stackoverflow.com/a/10517816/7724)。當你知道如何閱讀它時,堆棧痕跡非常有用。 :) – bzlm

+0

謝謝!明天我會和客戶一起看看。 – alfoks

回答