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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:36:26+00:00 2026-06-13T02:36:26+00:00

This is a bit of a general question. Say I have a class X

  • 0

This is a bit of a general question. Say I have a class X in A.dll and B.dll references A.dll and C.dll references B.dll.

Now, I need to use X in C.dll(the consumer code). So what I would want to do is to make a wrapper class X1 in B.dll and use that in the consumer code. So here’s the question? How to make X1 such that it is an (almost)perfect wrapper of X?

Thanks.

  • 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-06-13T02:36:27+00:00Added an answer on June 13, 2026 at 2:36 am

    .NET requires you to have a direct reference to A.dll if you use X or a class that inherits from X. Assuming that you do not want the consumer C.dll to reference A.dll directly, there are two ways. If you want to totally hide X, you should create a true wrapper (see example below). The alternative is to use late binding (not recommended, but C gets access to X with only an indirect assembly reference).

    Using a statically typed wrapper (preferred method)

    Assuming you want a wrapper (and not just inheriting X), I suggest you simply create a manual wrapper. I.e. create a class X1 that has a private variable of type X. Implement all public functions and properties of X by calling the corresponding member in X. This will work if all you need is a wrapper for X and nothing else. In this way, you can hide X from B (I assume that this is what you want).

    A.dll

    public class X {
       public int A { get; set; }
       public bool DoSomething() {
          A++;
       }
    }
    

    B.dll

    public class X1 {
       private X X;
       X1() {
           X = new X();
       }
       public int A { get { return X.A; } set { X.A = value } }
       public bool DoSomething() {
          return X.DoSomething();
       }
    }
    

    Using late binding (no manual wrapper needed)

    Not technically a wrapper, but if you want to avoid A.dll as a direct reference from C.dll

    A third alternative is not to wrap X, but to make C.dll use X as a unknown object. This method makes use of call sites and the ‘dynamic’ object in C#. This allows B.dll to return the true X without having to explicitly reference it at compile time from C.dll (assuming that you have a good reason not to do that). Microsoft creates so called ‘call sites’ for each property/function call from C.dll such that the overhead is very low. This makes X perfect as it is really X. The good thing about the dynamic method is that the wrapper will following any changes to X. The bad thing is that C.dll will have runtime binding (no compilation errors).

    public static class X1 {
       public static dynamic New() {
          return new X();
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have general question regarding the use of pointers vs. references in this particular
This question is about 64-bit Java apps in general, although I came upon it
So I have this bit of code for x in range(x1,x2): for y in
I have this bit of code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
i have this bit of code, it limits the Li's to 15 of them
This is a bit of a general question, but I will give a specific
This is bit of a general question but I wanted to know some different
This question is by necessity a bit general; it relates to the overall architecture
Ok i guess this is a bit of a general question really as opposed
This is more of a general question as I have found relatively little information

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.