try
{
some code
}
catch(Exception ex){System.Console.WriteLine("Exception" + ex.Message + " StackTrace: " + ex.Stacktrace);}