Objects based on Control and MarshalByRef

Hi all,
Hopefully you guys might have some good news for me. Currently in .NET 1.0 & 1.1 when trying to remote any object based upon System.Windows.Forms.Control across app domains fails due to, I believe, the ControlCollection not being serializable. The reason why the Control object itself would be marked MarshalByRefObject and then the contents couldn't be serialized is beyond me. It caused me my fair share of headaches. I am creating and application with a Plugin framework in which we wanted to load plugin assemblies into their own AppDomain so that we could isolate, maintain, and secure the plugins seperately from our main AppDomain. This worked well for everything expect when we tried to parent an object based on Control in one AppDomain to a object based upon Control in a seperate
AppDomain. We were doing this because we wanted to be able to host MDI Children forms defined in a plugin assembly in our main applications MDI parent form. This failed miserably. Is there any plans to support something like this in V 2.0 of the BCL? Any help would be appreciated.
John
--
Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways, chocolate in one hand, martini in the other, body thoroughly used up, totally worn out and screaming "WOO HOO what a ride!"
[1399 byte] By [JohnSheppard] at [2008-1-12]
# 1
I can't tell you if MS is planning to do anything like this in v2.0. Best to download and check the February CTP bits for yourself.

I can clarify MarshalByRefObject though. Classes which derive from MarshalByRefObject are remotable, but are not serialized. You essentially get a remotable pointer so you can call methods on the object, but the object never leaves the app domain it was created in. Any method calls from a remote app domain to a MarshalByRefObject are marshalled back to the original app domain where the object lives. So there is no need for ControlCollection to be [Serializable] - it will never be serialized because its parent (Control) will never be serialized.

Because you are going to be marshalling all calls between the child and parent components cross app domain, there will be some fairly high performance costs even if it is possible. You'll want to think long and hard about whether you need this high level of isolation between your main app and its plugins.

JamesKovacs at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Remoting and Runtime Serialization...

.NET Development

Site Classified