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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:02:28+00:00 2026-05-25T17:02:28+00:00

I had a discussion with friends last week about consuming the classes which are

  • 0

I had a discussion with friends last week about consuming the classes which are in DLL(.net DLL). I have a .net DLL which I need consume it in my Exe.

Normally,

  1. I add the DLL in my solution and reference the DLL in my Exe
  2. Create the object of the Class(which is in my DLL)
  3. Start calling methods /function in the class from the object just created.

But finally decided that, We should use Reflection not the way we are doing. Reason is Loose coupling. One can change the functionality in the DLL and compile it. In such situations, You don’t need to compile client code.

I have a question with this background.

Suppose, I have an a very simple application(Say console application) and I have two classes both are writtern to do different work.

class Program
{
    static void Main()
    {

        //How do you create a object of the class A. 

    }
}


class A
{

    string A = "I am from A";
    public B b; 
    public A
    {
        b = new B();

    }
}

class B
{

    string B = "I am from B";
    public B
    {

    }
    public void Print()
    {
        Console.WriteLine(B);
    }
}      

How do you create the object of Class A when all the three classes the same exe and how you create the same object when Class A and class B in different DLL.

one answer for the sencond part of the question is use interface and use reflection.

Is reflection is it really required, or it is kind of programming standard.

What is the best practice to create an object of the class.

  • 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-25T17:02:29+00:00Added an answer on May 25, 2026 at 5:02 pm

    Interfaces provide a way to have loose coupling.

    If you want to provide the ability to extend or replace the functionality after the fact without recompiling or even redeploying, then you’re basically looking at a plug-in type architecture on top of the interface based loose coupling.

    You could either use reflection to iterate and create an instance of the object but the other option is configuration/registration. For example, in your config file (or registry etc…) you could point to the file and class that implements that interface and use System.Activator to create it at runtime.

    Example:

    http://msdn.microsoft.com/en-us/library/ms972962.aspx

    Another more robust option is MEF. It’s a plug-in framework developed b the .net framework team.

    Check out this link:

    http://mef.codeplex.com/

    From that link (reenforcing your question):

    “Application requirements change frequently and software is constantly evolving. As a result, such applications often become monolithic making it difficult to add new functionality. The Managed Extensibility Framework (MEF) is a new library in .NET Framework 4 and Silverlight 4 that addresses this problem by simplifying the design of extensible applications and components. “

    Hope that helps.

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

Sidebar

Related Questions

I've just had a discussion with a developer about naming classes in C#. My
I had a little discussion with a friend about the usage of collections in
I had a discussion with a colleague at work, it was about SQL queries
Just had a discussion at work about the merits of using PostgreSQL over MySQL
i had a discussion with a coworker about the architecture of a program i'm
Today I had a discussion with a colleague about nested functions in Javascript: function
Today we had a discussion at the office about UI elements in the required
I friend of mine and I had a discussion a few days back about
I am pretty sure about my answer but today had a discussion with my
I've had quite a long discussion with a friend of mine about the correct

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.