Plus, if we want to catch SqlException, we need catch it as well. Or to use a common Exception to catch everything!
catch (System.Web.Services.Protocols.SoapException ex)
{
TextWriter log = TextWriter.Synchronized(File.AppendText(@"C:\CRM_Debug\error.txt"));
log.WriteLine("SoapException: " + DateTime.Now.ToString());
log.WriteLine("Error Message: " + ex.Detail.InnerText);
XmlDocument error = new XmlDocument();
error.LoadXml(ex.Detail.InnerXml);
log.WriteLine("Error Code: " + error.SelectSingleNode("/error/code").InnerText);
log.WriteLine("Error Description: " + error.SelectSingleNode("/error/description").InnerText);
log.WriteLine("Error Type: " + error.SelectSingleNode("/error/type").InnerText);
log.WriteLine();
log.Close();
}
catch (SqlException ex)
{
//
}
catch (Exception ex)
{
//
}