本文整理汇总了C#中System.Exception.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.GetHashCode方法的具体用法?C# Exception.GetHashCode怎么用?C# Exception.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.GetHashCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StringBuilder
string IExceptionFormatter.GetFormatString(Exception e, object attachObject)
{
HttpApplication app = attachObject as HttpApplication;
if(app == null) {
return e.ToString();
}
StringBuilder ret = new StringBuilder();
StreamReader streamReader = new StreamReader(app.Request.InputStream, app.Request.ContentEncoding);
ret.AppendFormat(formatMessage, e.Message, app.Request.HttpMethod, app.Request.Url.ToString(), e.GetHashCode(), app.Request.Headers, e.ToString(), streamReader.ReadToEnd(), app.Request.UserHostAddress, app.Server.MachineName, app.User.Identity.Name);
return ret.ToString();
}
示例2: LogException
public static void LogException(Exception exception)
{
if (exception != null)
{
try
{
string traceMessage = DateTime.Now + " : " + exception.Message;
if (exception.InnerException != null)
{
traceMessage += " : " + exception.InnerException.Message;
}
tracesource.TraceEvent(TraceEventType.Error, exception.GetHashCode(), traceMessage);
}
catch (Exception)
{
// Consume any exception while logging as it cannot be logged any more.
}
}
}
示例3: CreateWithoutStackInfo
/// <summary>
/// Creates a new instance of ExceptionDetails from a System.Exception and a parent ExceptionDetails.
/// </summary>
internal static ExceptionDetails CreateWithoutStackInfo(Exception exception, ExceptionDetails parentExceptionDetails)
{
if (exception == null)
{
throw new ArgumentNullException("exception");
}
var exceptionDetails = new External.ExceptionDetails()
{
id = exception.GetHashCode(),
typeName = exception.GetType().FullName,
message = exception.Message
};
if (parentExceptionDetails != null)
{
exceptionDetails.outerId = parentExceptionDetails.id;
}
return exceptionDetails;
}
示例4: DumpData
/// <summary>
/// Dumps an exception and data to the isolated storage.
/// </summary>
/// <param name="data"></param>
/// <param name="ex"></param>
public static void DumpData(byte[] data, Exception ex)
{
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
// Ensures the folder exists.
isf.CreateDirectory("/Debug");
// Gets the filename prefix.
string prefix = "/Debug/" + DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") +"_" + ex.GetHashCode() + "_";
// Dumps the data.
using (IsolatedStorageFileStream stream = isf.CreateFile(prefix + "ex_rawdata.txt"))
{
stream.Write(data, 0, data.Length);
}
// Dumps the stack trace.
using (IsolatedStorageFileStream stream = isf.CreateFile(prefix + "ex_stacktrace.txt"))
{
DumpException(ex, stream);
}
}
}
示例5: StringBuilder
string IExceptionFormatter.GetFormatString(Exception e, object attachObject)
{
const string formatMessage =
@"{0}
{1} {2}
hash code:{3}
request headers:
{4}
request data:
{6}
client ip:{7}
server name/ip:{8}
auth username:{9}
duration:{10}
error data:
{5}
";
var app = attachObject as HttpApplication;
if(app == null) {
var ctx = HttpContext.Current;
if(ctx == null) {
return e.ToString();
}
app = ctx.ApplicationInstance;
}
var duration = (DateTime.Now - app.Context.Timestamp).TotalMilliseconds;
var ret = new StringBuilder();
string body;
if(app.Request.Files.Count <= 0) {
var streamReader = new StreamReader(app.Request.InputStream, app.Request.ContentEncoding);
body = streamReader.ReadToEnd();
} else {//文件上传不保存请求内容(否则太大了)
body = WebHelper.NameValueCollectionToQueryString(app.Request.Form, app.Request.ContentEncoding);
}
ret.AppendFormat(formatMessage, e.Message, app.Request.HttpMethod, app.Request.Url, e.GetHashCode(), app.Request.Headers, e, body, app.Request.UserHostAddress, app.Server.MachineName, app.User.Identity.Name, duration);
return ret.ToString();
}
示例6: DumpException
/// <summary>
/// Dumps an exception to the isolated storage and on BugSense.
/// </summary>
/// <param name="ex"></param>
/// <param name="customMessage"></param>
/// <param name="dumpOnBugSenseToo"></param>
public static void DumpException(Exception ex, string customMessage = null, bool dumpOnBugSenseToo = false)
{
// BugSense dump.
if (dumpOnBugSenseToo && BugSenseHandler.IsInitialized)
{
BugSense.Core.Model.LimitedCrashExtraDataList extraData = null;
if (customMessage != null)
{
extraData = new BugSense.Core.Model.LimitedCrashExtraDataList();
extraData.Add("customMessage", customMessage);
}
BugSenseHandler.Instance.SendExceptionAsync(ex, extraData);
}
// Local dump.
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
// Ensures the folder exists.
isf.CreateDirectory("/Debug");
// Gets the filename prefix.
string prefix = "/Debug/" + DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") + "_" + ex.GetHashCode() + "_";
// Dumps the stack trace.
using (IsolatedStorageFileStream stream = isf.CreateFile(prefix + "stacktrace.txt"))
{
using (StreamWriter sw = new StreamWriter(stream))
{
DumpException((dynamic)ex, sw, customMessage);
}
}
}
}
示例7: Promise
public Promise(Exception exception)
{
_exception = exception;
_hashCode = exception.GetHashCode();
_waitHandle = new ManualResetEventSlim(true);
}
示例8: mException
private static ReturnValor mException(Exception ex)
{
ReturnValor oReturn = new ReturnValor();
StringBuilder sb = new StringBuilder();
sb.AppendLine(ex.GetType().FullName);
sb.AppendLine("Error Number: " + ex.GetHashCode().ToString());
sb.AppendLine("Source GEN: " + ex.Source);
sb.AppendLine("StackTrace: " + ex.StackTrace.ToString());
sb.AppendLine(ex.Message.ToString());
if (TExcep == "USER")
{
oReturn.Message = HelpMessages.ResourceManager.GetString(ex.GetHashCode().ToString());
if (string.IsNullOrEmpty(oReturn.Message))
oReturn.Message = ex.Message.ToString();
}
else if (TExcep == "ADMIN")
oReturn.Message = sb.ToString();
return oReturn;
}
示例9: HandleException
private bool HandleException(Exception ex)
{
if (ex is InstallException)
{
if (!_silent)
{
_console.WriteLine();
_console.WriteToConsole(ConsoleColor.Yellow, Strings.WARN_ServiceNotInstalled, _serviceName);
}
return true;
}
if (ex is InvalidOperationException)
{
if (ex.GetHashCode() == 55530882)
{
if (!_silent)
{
_console.WriteLine();
_console.WriteToConsole(ConsoleColor.Yellow, Strings.WARN_ServiceAlreadyInstalled,
_serviceName);
}
return true;
}
}
if (ex.InnerException != null)
{
if (ex.InnerException is Win32Exception)
{
// could be trying to install something that's already installed
// OR could be trying to start a service that isn't installed
if (!_silent)
{
_console.WriteLine();
//_console.WriteToConsole(ConsoleColor.Yellow, Strings.WARN_ServiceAlreadyInstalled,
// _serviceName);
_console.WriteToConsole(ConsoleColor.Yellow, ex.InnerException.Message, _serviceName);
}
return true;
}
_console.WriteLine();
_console.WriteToConsole(ConsoleColor.Yellow, ex.InnerException.GetType().FullName);
_console.WriteToConsole(ConsoleColor.Yellow, ex.InnerException.Message);
_console.WriteToConsole(ConsoleColor.Yellow,
ex.InnerException.GetHashCode().ToString(CultureInfo.InvariantCulture));
}
return false;
}
示例10: UpdateErrorArgs
public UpdateErrorArgs(Exception exception)
{
this.ErrorCode = exception.GetHashCode();
this.Message = exception.Message;
}
示例11: HandleException
protected void HandleException(Exception ex)
{
this.exception_label.Text = ex.GetType ().ToString ();
this.message_label.Text = ex.Message;
this.stacktrace_textview.Buffer.Text = ex.StackTrace;
this.exception_treeview.AppendColumn ("Name", new CellRendererText (), "text", 0);
this.exception_treeview.AppendColumn ("Type", new CellRendererText (), "text", 1);
this.exception_treeview.AppendColumn ("Value", new CellRendererText (), "text", 2);
TreeStore store = new TreeStore (typeof (string), typeof (string), typeof (string));
store.AppendValues (new string[] {"Class", ex.GetType().ToString(), ex.GetType().ToString()});
store.AppendValues (new string[] {"Message", ex.Message.GetType().ToString (), ex.Message});
store.AppendValues (new string[] {"Source", ex.Source.GetType().ToString(), ex.Source});
store.AppendValues (new string[] {"StackTrace", ex.StackTrace.GetType().ToString(), ex.StackTrace});
store.AppendValues (new string[] {"HashCode", ex.GetHashCode().GetType().ToString(), ex.GetHashCode().ToString()});
foreach (TreeViewColumn tvc in this.exception_treeview.Columns)
{
tvc.Resizable = true;
}
//this.exception_treeview.Columns[1].Expand = false;
this.exception_treeview.Model = store;
this.exception_treeview.HeadersVisible = true;
this.error_dialog.ShowAll ();
this.error_dialog.Run ();
this.error_dialog.Hide ();
}
示例12: GravarArqErroServico
/// <summary>
/// Grava um arquivo texto com um erros ocorridos durante as operações para que o ERP possa tratá-los
/// </summary>
/// <param name="arquivo">Nome do arquivo que está sendo processado</param>
/// <param name="finalArqEnvio">string final do nome do arquivo que é para ser substituida na gravação do arquivo de Erro</param>
/// <param name="finalArqErro">string final do nome do arquivo que é para ser utilizado no nome do arquivo de erro</param>
/// <param name="exception">Exception gerada</param>
/// <param name="errorCode">Código do erro</param>
/// <param name="moveArqErro">Move o arquivo informado no parametro "arquivo" para a pasta de XML com ERRO</param>
/// <remarks>
/// Autor: Wandrey Mundin Ferreira
/// Data: 02/06/2011
/// </remarks>
public static void GravarArqErroServico(string arquivo, string finalArqEnvio, string finalArqErro, Exception exception, ErroPadrao erroPadrao, bool moveArqErro)
{
int emp = Empresas.FindEmpresaByThread();
//Qualquer erro ocorrido o aplicativo vai mover o XML com falha da pasta de envio
//para a pasta de XML´s com erros. Futuramente ele é excluido quando outro igual
//for gerado corretamente.
if (moveArqErro)
MoveArqErro(arquivo);
//Grava arquivo de ERRO para o ERP
string pastaRetorno = Empresas.Configuracoes[emp].PastaXmlRetorno;
FileInfo fi = new FileInfo(arquivo);
if (fi.Directory.FullName.ToLower().EndsWith("geral\\temp"))
pastaRetorno = Propriedade.PastaGeralRetorno;
string arqErro = pastaRetorno + "\\" + Functions.ExtrairNomeArq(arquivo, finalArqEnvio) + finalArqErro;
string erroMessage = string.Empty;
erroMessage += "Versão|" + NFe.Components.Propriedade.Versao + "\r\n";
erroMessage += "ErrorCode|" + ((int)erroPadrao).ToString("0000000000");
erroMessage += "\r\n";
erroMessage += "Message|" + exception.Message;
erroMessage += "\r\n";
erroMessage += "StackTrace|" + exception.StackTrace;
erroMessage += "\r\n";
erroMessage += "Source|" + exception.Source;
erroMessage += "\r\n";
erroMessage += "Type|" + exception.GetType();
erroMessage += "\r\n";
erroMessage += "TargetSite|" + exception.TargetSite;
erroMessage += "\r\n";
erroMessage += "HashCode|" + exception.GetHashCode().ToString();
if (exception.InnerException != null)
{
erroMessage += "\r\n";
erroMessage += "\r\n";
erroMessage += "InnerException 1";
erroMessage += "\r\n";
erroMessage += "Message|" + exception.InnerException.Message;
erroMessage += "\r\n";
erroMessage += "StackTrace|" + exception.InnerException.StackTrace;
erroMessage += "\r\n";
erroMessage += "TargetSite|" + exception.InnerException.TargetSite;
erroMessage += "\r\n";
erroMessage += "Source|" + exception.InnerException.Source;
erroMessage += "\r\n";
erroMessage += "HashCode|" + exception.InnerException.GetHashCode().ToString();
if (exception.InnerException.InnerException != null)
{
erroMessage += "\r\n";
erroMessage += "\r\n";
erroMessage += "InnerException 2";
erroMessage += "\r\n";
erroMessage += "Message|" + exception.InnerException.InnerException.Message;
erroMessage += "\r\n";
erroMessage += "StackTrace|" + exception.InnerException.InnerException.StackTrace;
erroMessage += "\r\n";
erroMessage += "TargetSite|" + exception.InnerException.InnerException.TargetSite;
erroMessage += "\r\n";
erroMessage += "Source|" + exception.InnerException.InnerException.Source;
erroMessage += "\r\n";
erroMessage += "HashCode|" + exception.InnerException.InnerException.GetHashCode().ToString();
if (exception.InnerException.InnerException.InnerException != null)
{
erroMessage += "\r\n";
erroMessage += "\r\n";
erroMessage += "InnerException 3";
erroMessage += "\r\n";
erroMessage += "Message|" + exception.InnerException.InnerException.InnerException.Message;
erroMessage += "\r\n";
erroMessage += "StackTrace|" + exception.InnerException.InnerException.InnerException.StackTrace;
erroMessage += "\r\n";
erroMessage += "TargetSite|" + exception.InnerException.InnerException.InnerException.TargetSite;
erroMessage += "\r\n";
erroMessage += "Source|" + exception.InnerException.InnerException.InnerException.Source;
erroMessage += "\r\n";
erroMessage += "HashCode|" + exception.InnerException.InnerException.InnerException.GetHashCode().ToString();
}
}
}
try
//.........这里部分代码省略.........
示例13: SerializeWritesInnerExceptionWithOuterIdLinkingItToItsParentException
public void SerializeWritesInnerExceptionWithOuterIdLinkingItToItsParentException()
{
var innerException = new Exception();
var exception = new Exception("Test Exception", innerException);
ExceptionTelemetry expected = CreateExceptionTelemetry(exception);
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(expected);
Assert.Equal(exception.GetHashCode(), item.Data.BaseData.Exceptions[1].OuterId);
}
示例14: GenerateExceptionMessage
private void GenerateExceptionMessage(string message, Exception ex, LogLevel logLevel)
{
var exceptionMessage = string.Format("App message: {0}\nException: {1}\nException hashcode: {2}\n{3}", message, ex.Message, ex.GetHashCode(), ex.StackTrace);
Log(exceptionMessage, logLevel);
}
示例15: ErrorViewModel
public ErrorViewModel(Exception exception)
{
Exception = exception;
ErrorInfo = new ErrorInfo(exception.GetHashCode(), exception.Message, exception.StackTrace);
}