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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:41:40+00:00 2026-05-29T19:41:40+00:00

Consider the following code in a DLL: public class ReceivingClass { private Assembly myAssembly;

  • 0

Consider the following code in a DLL:

public class ReceivingClass
{
    private Assembly myAssembly;
    private Type typeOfClass;
    public ReceivingClass()
    {
        myAssembly = Assembly.LoadFile(@"E:\VSProjects\TestDynamicLinking\MyLib\bin\Debug\MyLib.dll");
        //Can I use this type somehow to resolve the type in the below method?
        typeOfClass = myAssembly.GetType("ExportedClass");
    }
    public bool ReceiveMethod(ExportedClass classobj)
    {
        return true;
    }
}

So, the problem is that in the ReceiveMethod above, ExportedClass is a class which is defined in the Assembly that I dynamically loaded in the Constructor. So, can I somehow resolve the type of ExportedClass such that I don’t have to use dynamic?

  • 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-29T19:41:42+00:00Added an answer on May 29, 2026 at 7:41 pm

    Some choices you have are either

    • Reference the actual assembly (probably not possible in your case as you load it dynamically),
    • Use a shared interface that the type implements (only if you can edit the loaded assembly),
    • or Use dynamic / reflection

    I would usually use the second approach. Just define an interface that ExportedClass implements in another (shared) assembly. Then you can try to cast the created instance to that interface. like that:

    ISomeInterface obj = Activator.CreateInstance(typeOfClass) as ISomeInterface;
    

    Of course, that is assuming that you have control over the referenced library. Or if you are defining a plugin infrastructure or something like that, you should include that as a requirement.

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

Sidebar

Related Questions

Consider the following Code snippet, Assembly asm = Assembly.LoadFile(DLL_Path); Type t = asm.GetType(DLL_NameSpace.MyClass, false,
Consider the following code: public partial class TeacherControlPanel : System.Web.UI.Page { protected string username
Consider the following code:- class Name { {System.out.println(hi);} public static void main(String[] args) {
Consider the following code: public abstract class RepositoryBase<T> where T : class { #region
Consider following code public class City { public string Name { get { return
Consider the following code, public class StartUp { public StartUp(String[] test){} public static void
Suppose you are given a Class.dll assembly compiled from the following simple code: namespace
Consider i have an assembly(class library dll) which i have loaded using the following
I got the following code that generate a DLL (sample exemple) : public class
please consider following code #include <iostream> using namespace std; class Digit { private: int

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.