Click here to Skip to main content
15,887,886 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I had hosted wcf service in IIS server. I am using that service from WPF application.
Suddenly exception error is coming from hosted service method.I have unable to take exception line number from hosted service method.

Is it possible to get that exception line number?

What I have tried:

private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
dynamic stackTrace_val = new StackTrace((e.Exception));
for (int i = 0; i <= stackTrace_val.FrameCount - 1; i++)
{
if ((method.DeclaringType.Assembly == Assembly.GetExecutingAssembly()))
{
dynamic stackFrame_val = stackTrace_val.GetFrame(i);
dynamic method = stackFrame_val.GetMethod();
Logger.Error("Exception in page :: " + (method.DeclaringType).FullName + ", Exception in method :: " + method.Name ", Exception in Line Number :: " + (new StackTrace(e.Exception, true)).frames[i].iLineNumber);
}
}
}
Posted
Comments
F-ES Sitecore 24-Mar-17 7:50am    
If the code has been compiled in release mode then the line numbers in your cs file no longer tally with what is being executed as the compiler will re-order, re-factor and delete your code as it sees fit. If you are having issues with a particular call you could always implement some debugging around that call and better exception handling to give you a better idea about what is going on in the code that is causing the issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900