.

The constructor to deserialize an object of type ??? was not found

See solution to my problem below – I got the following stack trace (error) while binary deserializing a class:

The constructor to deserialize an object of type ‘Microsoft.Skype.Horizon.Business.DataCollection.Exceptions.DataCollectionException’ was not found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.Serialization.SerializationException: The constructor to deserialize an object of type ‘Microsoft.Skype.Horizon.Business.DataCollection.Exceptions.DataCollectionException’ was not found.

Source Error:
return formatter.Deserialize(stream);

My code was:

[Serializable]
public class DataCollectionException : Exception
{
}
Solution:  simply add the following constructor

public DataCollectionException(SerializationInfo info, StreamingContext context)
        : base(info, context) { }

so that the code now looks like this:

[Serializable]
public class DataCollectionException : Exception
{
    public DataCollectionException(SerializationInfo info, StreamingContext context)
        : base(info, context)
    {
    }
}

What's your thoughts on this?

*

Protected by WP Anti Spam