當前位置: 首頁>>代碼示例>>C#>>正文


C# Exception.GetHashCode方法代碼示例

本文整理匯總了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();
 }
開發者ID:Angliy,項目名稱:DevFx,代碼行數:11,代碼來源:HttpWebExceptionFormatter.cs

示例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.
                }
            }
        }
開發者ID:hxhlb,項目名稱:wwt-tile-sdk,代碼行數:20,代碼來源:Logger.cs

示例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;
        }
開發者ID:kartang,項目名稱:ApmTipsTools,代碼行數:24,代碼來源:ExceptionDetails.cs

示例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);
				}
			}
		}
開發者ID:kamaelyoung,項目名稱:WF.Player.WinPhone,代碼行數:28,代碼來源:DebugUtils.cs

示例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();
 }
開發者ID:mer2,項目名稱:devfx,代碼行數:37,代碼來源:HttpWebExceptionFormatter.cs

示例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);
                    }
				}
			}
		}
開發者ID:WFoundation,項目名稱:WF.Player.WinPhone,代碼行數:40,代碼來源:DebugUtils.cs

示例7: Promise

 public Promise(Exception exception)
 {
     _exception = exception;
     _hashCode = exception.GetHashCode();
     _waitHandle = new ManualResetEventSlim(true);
 }
開發者ID:mesheets,項目名稱:Theraot-CF,代碼行數:6,代碼來源:Promise.cs

示例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;
        }
開發者ID:ocarril,項目名稱:UPC_TP3_ByS,代碼行數:22,代碼來源:HelpException.cs

示例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;
            }
開發者ID:LionFree,項目名稱:Cush,代碼行數:52,代碼來源:WindowsServiceManager.cs

示例10: UpdateErrorArgs

 public UpdateErrorArgs(Exception exception)
 {
     this.ErrorCode = exception.GetHashCode();
     this.Message = exception.Message;
 }
開發者ID:marinehero,項目名稱:ThinkAway.net,代碼行數:5,代碼來源:UpdateErrorArgs.cs

示例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 ();
 }
開發者ID:sgtnasty,項目名稱:battle,代碼行數:25,代碼來源:GladeWindow.cs

示例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
//.........這裏部分代碼省略.........
開發者ID:akretion,項目名稱:uninfe,代碼行數:101,代碼來源:TFunctions.cs

示例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);
        }
開發者ID:JoseCarlosMM,項目名稱:ApplicationInsights-dotnet,代碼行數:10,代碼來源:ExceptionTelemetryTest.cs

示例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);
 }
開發者ID:gep13,項目名稱:Emby.WindowsPhone,代碼行數:5,代碼來源:WPLogger.cs

示例15: ErrorViewModel

 public ErrorViewModel(Exception exception)
 {
     Exception = exception;
     ErrorInfo = new ErrorInfo(exception.GetHashCode(), exception.Message, exception.StackTrace);
 }
開發者ID:jdberrocal1,項目名稱:WebFundamentals,代碼行數:5,代碼來源:ErrorViewModel.cs


注:本文中的System.Exception.GetHashCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。