ModuleServiceProxy.GetErrorInformation 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取錯誤資訊。
public:
static System::String ^ GetErrorInformation(Exception ^ ex, System::Resources::ResourceManager ^ resourceManager, [Runtime::InteropServices::Out] System::String ^ % errorText, [Runtime::InteropServices::Out] System::String ^ % errorMessage);
public static string GetErrorInformation (Exception ex, System.Resources.ResourceManager resourceManager, out string errorText, out string errorMessage);
static member GetErrorInformation : Exception * System.Resources.ResourceManager * * -> string
參數
- resourceManager
- ResourceManager
ResourceManager 物件。
- errorText
- String
當這個方法傳回時,會包含與例外狀況相關聯的資源名稱。 這個參數會以未初始化的狀態傳遞。
- errorMessage
- String
當這個方法傳回時,包含與例外狀況相關聯的錯誤訊息。 這個參數會以未初始化的狀態傳遞。
傳回
ResourceName 屬性的值。
例外狀況
ex 參數或 resourceManager 參數為 null。
範例
下列範例示範 GetErrorInformation 方法。
private void GetSettingsMLP(object sender, DoWorkEventArgs e) {
try {
e.Result = _serviceProxy.GetSettings();
} catch (Exception ex) {
DisplayExceptionString(ex);
}
}
void DisplayExceptionString(Exception ex) {
string errAll = string.Empty, errTxt = string.Empty, errMsg = string.Empty;
string s = ModuleServiceProxy.GetErrorInformation(ex, _resourceMgr, out errTxt, out errMsg);
errAll = "ModuleServiceProxy.GetErrorInformation return \n\t\"" + s +
" \"\n\t Error Text = " +
errTxt + "\n \t Error Msg = " + errMsg;
if (ex.InnerException != null)
errAll += "\n\n ************ InnerException ************ \n" +
ex.InnerException.Message +
"\n ************ End InnerException ************ \n";
errAll += ex.StackTrace;
System.Windows.Forms.MessageBox.Show(errAll + "\n" + ex.Message, "Error in : " + ex.Source);
}