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 5939509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:50:18+00:00 2026-05-22T15:50:18+00:00

Is it possible for the CLR to create Object X that inherits from Object

  • 0

Is it possible for the CLR to create Object X that inherits from Object Y where

  • Object Y is of type Object
  • All methods of Y are available to object X.
  • Callers of Object X think they see all of Y’s objects
  • Object X masks the methods above and does some ‘work’ prior to running each method
  • That ‘work’ may include counting the number of calls, or some arbitrary code
  • Object X should be able to work against any object (It’s OK if it doesn’t work against Sealed objects)

An alternate implementation might use Generics where Object T<Y> exposes all the methods, events, and properties of contained object Y

  • 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. Editorial Team
    Editorial Team
    2026-05-22T15:50:19+00:00Added an answer on May 22, 2026 at 3:50 pm

    Yes. This is called proxying an object. Castle DynamicProxy is designed for doing exactly this. Krzysztof Koźmic has produced an excellent tutorial about it.

    It works by creating an object (X in your scenario) at runtime which inherits from the object you want to proxy (object Y). You provided an object which implements IInterceptor which gets called when certain methods are invoked – you specify these in a proxy generation options class.

    The only caveat is that the methods you wish to intercept must be virtual, but you can probably get around this by wrapping the object to proxy in another which does provide virtual methods (although I’d guess you probably want to proxy the object because doing this is a real pain).

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

Sidebar

Related Questions

I have a CLR UDT that would benefit greatly from table-valued methods , ala
Is it possible to create a Command Link button in Visual C++ (CLR/Windows Forms
This post says that it is possible to turn off the CLR flag for
Possible Duplicate: Casting vs using the ‘as’ keyword in the CLR Which method is
Are multi-threaded CLR stored procs possible? I have a data-intensive task with lots of
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: CLR and CLI - What is the difference? What is the difference
Is it possible to call CLR DLL (one for example which is made with
Possible Duplicate: TFS 2010 Custom Build Activity TF215097 error I'm trying to create a

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.