How to write log in Runtime Error situation?
I want to know where the error occurred at source code.(When I execute .exe
file)
(I don't use Serial debugging
)
You can use print the exception using Debug.WriteLine
catch (Exception ex)
{
Debug.Writeline(ex.ToString());
}
There is a catch in using for Compact framework, it wont have the same behaviour. But you can try this.
On Windows CE, any information passed to Debug.Write is displayed in a temporary console window on the device. The console window automatically opens on the fist call to Debug.Write and closes immediately after the application exits. The console window can be kept open by placing a breakpoint at the end of the application's Main() function, to prevent the application from completely exiting.
More details - https://msdn.microsoft.com/en-us/library/aa446495.aspx