C # Exception Include Event Details
I am new to C # and Windows development in general. I need to use it to build an integration between our data in MySQL and Microsoft Dynamics GP (using eConnect). This part is not very relevant, but adds a bit of context to the examples below.
Ok, so when I connect to the service:
eConnectClient client = new eConnectClient();
string newCustomerDocument = "SOME_XML_HERE";
string connectionString = "Data Source=localhost;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=GPVPM;";
try
{
client.Open();
bool result = client.CreateEntity(connectionString, newCustomerDocument);
}
catch (FaultException<eConnectFault> e)
{
Console.Write("ECONNECT FAULT: " + e.ToString() + "\n");
}
Now if I have an error in my XML this will trigger a call FaultException
, but the resulting exception message is useless:
ECONNECT FAULT: System.ServiceModel.FaultException`1 [GPConnect.eConnect.eConnectFault]: The creator of this error did not provide a reason. (Fault Detail equals GPConnect.eConnect.eConnectFault).
I found that if I look at Event Viewer for Windows it paints a completely different picture of what happened:
In particular:
Error Number = 250 Stored Procedure = taUpdateCreateCustomerRcd Error Description = Tax Schedule does not exist in the Tax Schedule Master Table
So this is something actionable that can help me identify the problem and fix it.
Question:
With C #, how can I get the same level of detail from the Exception as recorded by the event dispatcher?
source to share