Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 75169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:28:27+00:00 2026-05-10T20:28:27+00:00

How to solve Must be MarshalByRefObject in a good but multiple-inheritance amputated language like

  • 0

How to solve ‘Must be MarshalByRefObject’ in a good but multiple-inheritance amputated language like C#?

The problem is very simple, in several cases you just have to inherit from this class (infrastructure requirements). It does not matter here really, which cases. So, what do you do if you’ve already inherited from some other class (your domain model requirements)?

Btw good application frameworks, like spring.net always make sure you DON’T have to inherit from this class no matter what kind of infrastructure you need to apply to your class.

I would like to know what am I getting -3 votes here for?? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:28:27+00:00Added an answer on May 10, 2026 at 8:28 pm

    In general you only want to make an object MarshalByRef if you’re going to use it in a Remoting / WCF context. This is usually a special-enough case that it’s not a pain.

    Suppose you had a general type, and you wanted to derive from it and specialise it, and then remote the derived type – now you have a problem, because to be remoted an object must inherit from MarshalByRefObject, and your original general type didn’t. Suppose you can’t change it because you’re doing binary inheritance, or because it itself derives from a base class you can’t change? As the questioner points out, since C# (and .NET in general) doesn’t allow MI, you can’t inherit from both.

    The short answer is that you’re sort-of screwed. You either change the general type to inhert from MarshalByRefObject (or go far enough up the chain that you can insert it somewhere effective), or else you can think about mucking about with proxy objects.

    You could for example create an interface contract that describes your type’s interface, and then build a proxy type inheriting from MarshalByRefObject that also implements that interface by composition and delegation to an instance of your type (ie a wrapper). You could then remote an instance of that proxy type which would instantiate your type and do the work as expected – but all return types from methods have to be [Serializable].

    public interface IMyType {     string SayHello();     string BaseTypeMethodIWantToUse(); }  public class MyType : MyBaseType, IMyType {     public string SayHello()     {         return 'Hello!';     } }  public class MyRemoteableType : MarshalByRefObject, IMyType {     private MyType _instance = new MyType();      public string SayHello()     {         return _instance.SayHello();     }      public string BaseTypeMethodIWantToUse()     {         return _instance.BaseTypeMethodIWantToUse();     } } 

    Seems like a lot of work, though. Ultimately if you’re in this scenario I’d suggest a redesign or a rethink.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 257k
  • Answers 258k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can do it in one sql statement for existing… May 13, 2026 at 10:52 am
  • Editorial Team
    Editorial Team added an answer Wow, this is a tough one. Most websites have fixed… May 13, 2026 at 10:52 am
  • Editorial Team
    Editorial Team added an answer I tried this a couple of hours later and it… May 13, 2026 at 10:52 am

Related Questions

Feel free to edit the title if you know how to formulate the question
I am looking here for some hints and tips on how to manage multiple
I've written this to try and log onto a forum (phpBB3). import urllib2, re
I've been asked to provide support for authenticating users against an Active Directory in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.