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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:23:15+00:00 2026-06-11T02:23:15+00:00

I dynamically load an assembly as: var assembly = Assembly.LoadFile(PathOFMyDll); anyways that assembly has

  • 0

I dynamically load an assembly as:

 var assembly = Assembly.LoadFile("PathOFMyDll");

anyways that assembly has the static method Filter inside the class DynamicClass. So once I have that assembly I exececute that method as:

 var filter = assembly.GetType("DyamicClass").GetMethod("Filter");

 // that method accepts a object as parameter
 filter.Invoke(null, new object[] { "test" });

Now my question is:

I have the delegate delegate bool FilterDelegate(object item); why it is not possible make a delegate of that type point to that method in order to have:

 FilterDelegate myPointerToMethodFilter = (FilterDelegate)assembly.GetType("DyamicClass").GetMethod("Filter");
 bool result = myPointerToMethodFilter("test");

note the compiler only complains when trying to compile. I do not get any syntax errors.

  • 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-11T02:23:17+00:00Added an answer on June 11, 2026 at 2:23 am

    It is possible to create a delegate from a MethodInfo object, but casting is not sufficient.

    Instead, use Delegate.CreateDelegate():

    MethodInfo myMethodFilter = assembly.GetType("DyamicClass").GetMethod("Filter");
    FilterDelegate myPointerToMethodFilter = (FilterDelegate)Delegate.CreateDelegate(typeof (FilterDelegate), myMethodFilter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that dynamically load 10 different textfields in viewdidload method now if
I am using an 3rd party assembly that provides services via a static class:
I have a class that is designed to dynamically load a .dll or .so
I am trying to come up with a method factory that looks inside config
I have a WPF project where I load a WindowsForsm assembly (dll file) dynamically
I'm trying to load an assembly at runtime. For that I'm using the following
I'd like to dynamically load and use a .Net assembly created in C# from
I am trying to load an assembly dynamically and create an variable of its
I have an application that has reference to Microsoft.Data.SqlXml.dll assembly (part of SQLXML ).
I am debugging an assembly which I loaded dynamically with Assembly.Load(Byte[]) , but 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.