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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:52:23+00:00 2026-05-24T05:52:23+00:00

I have been reading a lot about this – I feel like I’m very

  • 0

I have been reading a lot about this – I feel like I’m very close to the answer. I am simply looking to call a method from within a dll file that I have created.

For example purposes:

My DLL File:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExampleDLL
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Windows.Forms.MessageBox.Show(args[0]);
        }

        public void myVoid(string foo)
        {
            System.Windows.Forms.MessageBox.Show(foo);
        }
    }
}

My Application:

string filename = @"C:\Test.dll";
    Assembly SampleAssembly;
    SampleAssembly = Assembly.LoadFrom(filename);
    // Obtain a reference to a method known to exist in assembly.
    MethodInfo Method = SampleAssembly.GetTypes()[0].GetMethod("myVoid");
    // Obtain a reference to the parameters collection of the MethodInfo instance.

All credits go to SO user ‘woohoo’ for the above snippet
How to call a Managed DLL File in C#?

Now, though, I would like to be able to not only reference my Dll (and the methods inside it) but properly call the methods inside it (in this case I would like to call method ‘myVoid’).

Might anyone have any suggestions for me?

Thank you,

Evan

  • 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-24T05:52:23+00:00Added an answer on May 24, 2026 at 5:52 am

    The question and answer you reference is using reflection to call the method in the managed DLL. This isn’t necessary if, as you say you want to do, you simply reference your DLL. Add the reference (via the Add Reference option in Visual Studio), and you can call your method directly like so:

    ExampleDLL.Program p = new ExampleDLL.Program(); // get an instance of `Program`
    p.myVoid(); // call the method `myVoid`
    

    If you want to go the reflection route (as given by woohoo), you still need an instance of your Program class.

    Assembly SampleAssembly = Assembly.LoadFrom(filename);
    Type myType = SampleAssembly.GetTypes()[0];
    MethodInfo Method = myType.GetMethod("myVoid");
    object myInstance = Activator.CreateInstance(myType);
    Method.Invoke(myInstance, null);
    

    Now you have an instance of Program and can call myVoid.

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

Sidebar

Related Questions

I have been reading a lot about QR codes and how the code itself
I have been reading a lot about C++ casting and I am starting to
Lately I have been reading a lot of blog topics about big sites(facebook, twitter,
I have been reading a lot about how flash development/design had died, and as
I have been reading a lot about how and why to use an MVC
I have been reading a lot about dependency injection recently, and in theory it
I have been reading a lot about test-driven development and decided that I want
I have been googling a lot about this, but I can't find a specific
I have been reading a lot about MVC these days and I think I
I am currently reading a lot about Design Patterns and I have been watching

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.