Delegate.Combine()

Is there a way to combine delegates in-place

I'm trying to deserialize a delegate for which I need to create an unitialized Delgate (via FormatterServices.GetUnitializedObject) in order to resolve references during deserialization. Once all references are resolved, the delegate will need to be initialized but the refererence to the unitialized multicast delegate cannot change.

I can use reflection to initialize the delegate and the Combine method provides a way to add delegates to the invocation list but combining delegates produces a reference to the combined delegate destroying the original reference resolution.

Thanks,
Ray


Answer this question

Delegate.Combine()

  • Bill_Thompson

    Hello Ray,

    The result of delegate operations is a new delegate - essentially making them immutable. This is by design, although I'm presently aware of the original reasons why [although I have some ideas].

    What are you trying to do that the delegate reference cannot change Are you pinning it for interop purposes

    Thanks,
    Stephen
    http://blogs.msdn.com/stfisher

  • fedrok

    This was in the context of trying to serialize/deserialize the fields of multicast delegates. I've since then learned that they are serialized as a different type (DelegateSerializationHolder( )) and was not taking that into account.

    Thanks,
    Ray

  • Delegate.Combine()