Is showing the Exception StackTrace useful in a RELEASE assembly or only a DEBUG .dll

不想你离开。 提交于 2019-12-23 04:21:11

问题


I've gone to some lengths to improve the error handling in my webservice - in particular, showing the StackTrace as in this example:

catch (Exception ex)
        {
            EventLog log = new EventLog();
            log.Source = g_EventSource;
            StringBuilder msg = new StringBuilder("Exception in UpdateRecord method has been logged:");
            msg.Append(Environment.NewLine);
            msg.Append("passedURL="); msg.Append(passedURL);
            msg.Append(Environment.NewLine);
            msg.Append(ex.Message);
            msg.Append(Environment.NewLine); 
            msg.Append(ex.Source);
            msg.Append(Environment.NewLine);
            msg.Append(ex.StackTrace);
            log.WriteEntry(msg.ToString(), EventLogEntryType.Error, 100);
            return msg.ToString();
        }

My question is what will happen when I publish my webservice having compiled it as RELEASE instead of DEBUG? I only publish the .dll and the web.config (no source) now when I compile in DEBUG mode but when an error is logged the StackTrace points back to line numbers of file(s) in my development machine like:

C:\Documents and Settings\johna\My Documents\Visual Studio 2008\Projects\   etc.

In short, will a RELEASE mode DLL still show the above sort of stack trace? I think it will but not sure; my system administrator has raised this question as we prepare for a move into another level of deployment.


回答1:


You can have line numbrers in Stack Trace messages but you need to include .PDB files. No problems even in release mode.



来源:https://stackoverflow.com/questions/1850253/is-showing-the-exception-stacktrace-useful-in-a-release-assembly-or-only-a-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!