Home Comments

ICE for C#: Exceptions not serializable

kwaclawkwaclaw Oshawa, CanadaMember Karl WaclawekOrganization: Personal
I am running into a problem with ICE exceptions not able to cross application domain boundaries. When such an exception propagates to the main/parent application domain I get a SerializationException in System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeObject().

It is a recommended .NET practice to make custom exceptions serializable, that is mark them with the Serializable attribute, and (if custom members were added) implement GetObjectData(). See Designing Custom Exceptions and Commonality - Make Exception Classes Serializable. Maybe that could be added to the C# code generator.

Also, it is now a deprecated recommendation to derive custom exceptions (like in ICE) from System.ApplicationException. They should be derived from System.Exception instead. See Designing Custom Exceptions and ApplicationException Class (System). A possible change for ICE (I can't imagine this has much of an impact).
Sign In or Register to comment.