When a exception in the .net server happend, I only get on the client the main description, but not the more useful traceback.
For example I’m getting this when try to apply updates on a dataset:
Project CatalogSync.exe raised exception class EROUnregisteredServerException with message ‘An exception was raised on the server: Input string was not in a correct format.’.
Could be more useful if can get more info about this.
First of all, the code you’ve sent is for handling of exceptions that was unhandled by your application logic. They are not supposed to be sent the client. Clients receive only exception that were occurred during processing of current user request to server Service. Also such exceptions are not re-raised on server, so you can’t catch them with AppDomain.CurrentDomain.UnhandledException handler.
Secondly, usually server message component send exceptions that are either inherited from or wrapped with the ServerException class that has a ServerStackTrace property. So, on DA client for .Net you can use next code to catch such exception:
I prefer to log the errors in the server, not show in the client. The server will be a public cloud service so is important to log the exceptions to take measures…
To log unhandled exceptions on server (both from main or worker threads) you can use our class AplicationServer The good example of using it will be a server application project, generated by DataAbstract Wizard. In it select option Client and a New Custom DA Server on the first page. In generated project, look at Program.cs source file.
But DA server components is build in manner to prevent their fall due to some client request. Thus almost all exception on server side are caught within correspondent component.
In that case, to see what’s happening on the server side, I suggest you look at the approach that is used in our DA Sample Server to log server side activity. DataService provides events you can handle to log errors.
Another option is to catch all exceptions, that server is going to send to client. Handle OnInitializeMessage event to do this:
Project Project1.exe raised exception class EROUnregisteredServerException with message ‘An exception was raised on the server: No such host is known’.
However, I don’t get on _OnInitializeMessage the exception. So I change my code to use “AplicationServer” base class, neither it get logged when pass the -D param to the server.
As I understand the exception above was raised on client side and is related to communication problem between server and client. According to text “No such host is known” the reason was in resolving server ip address by its dns name. Anyway, it was a client error and that’s why it was not caught by your server exception handlers.
But such errors can be handled on client side (or at least logged) by subscribing on ClientChannel.OnException event. More about this exception here.