Is it possible to deserialize delegates to non-public methods?

Deserializaton of the object graph inside a program I'm working on fails
with the following exception:

> A first chance exception of type
> 'System.Runtime.Serialization.SerializationException' occurred
> in mscorlib.dll
>
> Additional information: Serialization will not deserialize delegates
> to non-public methods.

Looking at the call stack and using Anarkino, it seems that this exception
is thrown by the following code inside
DelegateSerializationHolder.GetDelegate:

private Delegate GetDelegate(DelegateEntry de) {
    Delegate local0;
    MethodInfo local5;

    ...

    local5 = local0.Method;
    if (local5 != null && !(local5.IsPublic))
        throw new SerializationException(Environment.GetResourceString
            ("Serialization_RefuseNonPublicDelegateCreation"));
     return local0;
}

However, I have created a minimal test case where a simple object contains
an event handler with a delegate pointing to a private method of another
simple object. In that case serialization seems to work.

Any ideas?

Thanks,
Dejan
www.jelovic.com

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to