I have a WCF service with one async method, updateUsers. The username is unique, so when I save changes, if exists a username that is assign to a new user, I get an UpdateException.
I Create a custom exception, UniqueKeyUsersException, that have three properties, a int64 with the ID and two strings, one for the username and other with the password. By the moment are all the fields that there are in the table of the database.
This exception, are decorate as Serializable and implements the ISerializable interface. With this, I can send the information to the client. If I do not implement this interface, to the client arrives the exception, but all the properties are null.
All works fine, to the client arrives the FaultException with the information of the username that exists.
However, I am thinking in the possibility to use only one property in the exception, of type Users, that is a self tracking entity that I have in an external library. The idea is to send to the client the entity with the register that exists in the database, so the user can decide to see the information of the existing user. In this way, the user save the needed to do a new query. If I would send the exception with my three properties, I would have to create a new object Users and convert the information from the exception to the Users entity.
My problem is that when I add in the exception a property of type Users (a STE) when I throw the FaultException, it fails, crash the service. I think that it could be for serialization reasons, that perhaps it's needed, in the implementation of the ISerialize, add the serialization of the STE.
But it would be a lot of work, because the STE has not only the information of the database, but also the tracking of the entity and other properties.
So my question is if exists any way to use a STE as property of the exception or I can only use basic types?
Thanks. Daimroc.