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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:10:24+00:00 2026-06-04T07:10:24+00:00

I want to load an assembly ( dll-test.dll ), and run the method GetLabel

  • 0

I want to load an assembly (dll-test.dll), and run the method GetLabel:

namespace Dlltest.Test
{
    public class Main
    {
        public string GetLabel()
        {
            string test = "TestString";
            return test;
        }
    }
}

I have the following code however I cannot get to run GetLabel:

Assembly assembly = Assembly.LoadFile(@"C:\dll-test.dll");
Type type = assembly.GetType();
var obj = Activator.CreateInstance(type);

var result = type.InvokeMember("GetLabel",
                              BindingFlags.Default | BindingFlags.InvokeMethod,
                              null,
                              obj,
                              null);

MessageBox.Show(result.ToString);

It should show a message box with TestString.

Edit

I eventually made it working with:

Assembly assembly = Assembly.LoadFile(@"C:\dll-test.dll");
var type = assembly.GetTypes();
var obj = Activator.CreateInstance(type[0]);

var result = type[0].InvokeMember("GetLabel",
                          BindingFlags.Default | BindingFlags.InvokeMethod,
                          null,
                          obj,
                          null);

MessageBox.Show(result.ToString());
  • 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-04T07:10:25+00:00Added an answer on June 4, 2026 at 7:10 am

    In line

    Type type = assembly.GetType();
    

    you’re assigning type of assembly variable instead of the type that you want. Try assembly.GetType(type_name). Moreover change “GetGabel” into “GetLabel” 🙂

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

Sidebar

Related Questions

I want to load two assemblies from C++/CLI; assembly A depends on assembly B,
my application want to call a method of a class that is from another
I want to list down all the types mentioned in a DLL(assembly) which has
I have a WPF project where I load a WindowsForsm assembly (dll file) dynamically
I want to use this code to grab all methods from the assembly Mscorlib.dll
How do I load a dll and its dependencies? I don't want to place
I want to call a method of a DLL via reflection (can't be sure
I want load xml documents, but there are special symbols like : ąčęėįšųū and
at first sorry my bad English I want load model in my plugin controller
I want to load the content of a div on the mouseover of an

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.