本文整理汇总了C#中System.ServiceModel.FaultException.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# FaultException.ToString方法的具体用法?C# FaultException.ToString怎么用?C# FaultException.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.FaultException
的用法示例。
在下文中一共展示了FaultException.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FinishWithFaultException
/// <summary>
/// Handles fault exception during publishing
/// </summary>
/// <param name="CustomFaultException"></param>
private void FinishWithFaultException(FaultException fe)
{
boolError = true;
string statusMessage = "Fault Exception";
AddStatusMessage(statusMessage);
btnShowLog.Enabled = true;
txtStatusSummary.Text = statusMessage;
txtStatus.AppendText(fe.ToString());
btnDetails.Visible = true;
this.progressBar.Visible = false;
this.Cursor = Cursors.Default;
panel2.Visible = false;
lblSuccessNotice.Text = "Fault Exception";
lblSuccessNotice.BackColor = Color.FromArgb(243, 217, 217);
panel3.Visible = true;
lblSuccessNotice2.Visible = false;
}
示例2: GetPSClientError
/// <summary>
/// Extract a PSClientError object from the ServiceModel.FaultException,
/// for use in output of the GetPSClientError stack of errors.
/// </summary>
/// <param name="e"></param>
/// <param name="errOut">Shows that FaultException has more information
/// about the errors than PSClientError has. FaultException can also contain
/// other types of errors, such as failure to connect to the server.</param>
/// <returns>PSClientError object, for enumerating errors.</returns>
public static PSLibrary.PSClientError GetPSClientError(FaultException e,
out string errOut)
{
const string PREFIX = "GetPSClientError() returns null: ";
errOut = string.Empty;
PSLibrary.PSClientError psClientError = null;
if (e == null)
{
errOut = PREFIX + "Null parameter (FaultException e) passed in.";
psClientError = null;
}
else
{
// Get a ServiceModel.MessageFault object.
var messageFault = e.CreateMessageFault();
if (messageFault.HasDetail)
{
using (var xmlReader = messageFault.GetReaderAtDetailContents())
{
var xml = new XmlDocument();
xml.Load(xmlReader);
var serverExecutionFault = xml["ServerExecutionFault"];
if (serverExecutionFault != null)
{
var exceptionDetails = serverExecutionFault["ExceptionDetails"];
if (exceptionDetails != null)
{
try
{
errOut = exceptionDetails.InnerXml + "\r\n";
psClientError =
new PSLibrary.PSClientError(exceptionDetails.InnerXml);
}
catch (InvalidOperationException ex)
{
errOut = PREFIX + "Unable to convert fault exception info ";
errOut += "a valid Project Server error message. Message: \n\t";
errOut += ex.Message;
psClientError = null;
}
}
else
{
errOut = PREFIX + "The FaultException e is a ServerExecutionFault, "
+ "but does not have ExceptionDetails.";
}
}
else
{
errOut = PREFIX + "The FaultException e is not a ServerExecutionFault.";
}
}
}
else // No detail in the MessageFault.
{
errOut = PREFIX + "The FaultException e does not have any detail.";
}
}
errOut += "\r\n" + e.ToString() + "\r\n";
return psClientError;
}
示例3: TestToString
public void TestToString ()
{
FaultException<int> e = new FaultException<int> (0);
Assert.AreEqual (
String.Format ("{0}: {1} (Fault Detail is equal to {2}).", e.GetType (), e.Message, e.Detail),
e.ToString ());
}