Issues with inheriting from MarshalByRefObject

  • Thread starter Thread starter Dan Holmes
  • Start date Start date
D

Dan Holmes

I am in a jam. Since C# (or the CLR) doesn't support MI i need to
create either two inheritance hierarchies or have all my object inherit
ultimately from MarshalByRefObject.

I noticed that Windows.Forms.Form also ultimately inherits from
MarshalByRefObject with not a lot of complaints from the .NET community
so i wonder if i should follow MS's pattern.

Thoughts...

dan
 
If you need to inherit from 2 objects, I would use the Fascade pattern to
hide the implentations of the 2 inherited classes and make the fascade class
inherit from MarshallByRef object. You will have to redeclare your
abstract/virtual methods in the fascade class.
For more info, see http://www.dofactory.com/Patterns/PatternFacade.aspx

Hope I have helped.
--
Good luck!

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
 
Dan Holmes said:
I am in a jam. Since C# (or the CLR) doesn't support MI i need to
create either two inheritance hierarchies or have all my object inherit
ultimately from MarshalByRefObject.

Why? You haven't described why you need to derive from
MarshalByRefObject to start with.

I believe there are (or at least were) some JIT optimisations which
aren't applied to classes deriving from MarshalByRefObject. Without
more information, it's hard to say whether or not that's important to
you.
 
Jon said:
Why? You haven't described why you need to derive from
MarshalByRefObject to start with.

I believe there are (or at least were) some JIT optimisations which
aren't applied to classes deriving from MarshalByRefObject. Without
more information, it's hard to say whether or not that's important to
you.
I have a distributed windows forms app. There is a set of classes that
are served by remoting and a set that reside on the client with the form.

The client side classes have a remoted counterpart (hence the
MarhsalByRefObject). Both classes would inherit the same interfaces but
they can't inherit the same base class because the remoted objects need
to derive from MarshalByRefObject. I could simplify the class hierarchy
if being derived from MarshalByRefObject isn't a hindrance if the
intention is to only be used from within the current app domain.

dan
 
Dan Holmes said:
I have a distributed windows forms app. There is a set of classes that
are served by remoting and a set that reside on the client with the form.

The client side classes have a remoted counterpart (hence the
MarhsalByRefObject). Both classes would inherit the same interfaces but
they can't inherit the same base class because the remoted objects need
to derive from MarshalByRefObject. I could simplify the class hierarchy
if being derived from MarshalByRefObject isn't a hindrance if the
intention is to only be used from within the current app domain.

I don't know of anything other than the potential performance hit, and
you'd have to check that. Of course, there may be things I'm not aware
of...
 
Back
Top