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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:25:46+00:00 2026-06-12T16:25:46+00:00

I want to load a type at run time using reflection. Below are the

  • 0

I want to load a type at run time using reflection. Below are the steps:

  1. Load the assembly using Assembly.LoadFile(assemblyPath);
  2. Use the GetType method to obtain the type
  3. Use Activator.CreateInstance to create the instance of type.

Below is my code:

Assembly assembly = Assembly.LoadFile(assemblyName);
Type type = assembly.GetType("RomanConerter.Converter");
object obj = Activator.CreateInstance(type);

Problem I am facing is with the last line. My Converter has one method name Add. But I cannot access this method using obj.

Note: The assembly which I am trying to load in in other project, and I have hasrd coded the path.

Can anyone help me out please ?

  • 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-12T16:25:48+00:00Added an answer on June 12, 2026 at 4:25 pm

    This all depends on whether the type RomanConverter.Converter is available to you in your calling application (i.e. that contains the code you’ve posted). If so, then you just cast.

    If not – then you can late-bind the method with reflection (as others have said) or use dynamic, but imho you’d do better to use a common base or interface:

    /* common interface used in both your code and the external DLL */
    public interface ICanAdd {
      object Add(object source);
    }
    

    (I’m guessing the signature here)

    And then change this plug-in type of yours to:

    namespace RomanConverter {
      public class Converter : ICanAdd {
        object Add(object source){
          //TODO: implement
        }
      }
    }
    

    Now when you get the object from Activator.CreateInstance you just cast to ICanAdd:

    ICanAdd obj = (ICanAdd)Activator.CreateInstance(type);
    

    Now you can call the method.

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

Sidebar

Related Questions

I want to load the form fields using json data. I am using extjs
I want to load multiple languages to use IVONA SDK with SSML for iPhone.
I am loading some assemblies at run time and invoking methods on them using
I want to use textures in opengl on my C# application. I'm using the
These are similar questions: How-to: Load a type from a referenced assembly at runtime
I currently have a DLL (done using C++). Now I want to load this
at first sorry my bad English I want load model in my plugin controller
I want to load an image via css that stretches to the entire screen.
I want to load up a random image while a page it is loading
I want to load data from MySql database to a HTTP form When I

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.