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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:35:13+00:00 2026-06-06T17:35:13+00:00

I’m trying to load a type from a different assembly (not known at build

  • 0

I’m trying to load a type from a different assembly (not known at build time) as ‘dynamic’ and execute a method on that type. My goal is to completely disconnect the ‘plugin’ from the parent application such that there is no requirement for any shared code or common interface type. The interface is implied by way of an expected method signature on the loaded type.

This works:

dynamic myObj = Assembly.Load("MyAssembly").CreateInstance("MyType");
myObj.Execute();

However this will load the type into the current AppDomain along with all its dependent assemblies.
I want to modify this to allow me to do that same thing in a separate AppDomain.

This works but doesn’t make use of the dynamic keyword, I need to know the explicit type that I am instantiating to be able to call the Execute method:

var appDomain = AppDomain.CreateDomain(domainName, evidence, setup);
var myObj = appDomain.CreateInstanceAndUnwrap(assembly, type);
typeof(IMyInterface).InvokeMember("Execute",  BindingFlags.InvokeMethod, null, myObj);

This is essentially my target case and I have been trying to get something like this working:

dynamic myObj = ad.CreateInstanceAndUnwrap(assembly, type);
myObj.Execute();

I keep ending up with a RuntimeBinderException with the message “‘System.MarshalByRefObject’ does not contain a definition for ‘Execute'”. This message makes sense, sure it doesn’t contain a definition for ‘Execute’, but I know the type that I am instantiating does indeed contain an ‘Execute’ method. I imagine there’s something going on here with the transparent proxy that is preventing this from working but I’m not sure what.

My actual class that I am trying to instantiate looks like this:

[Serializable]
public class MyClass : MarshalByRefObject {
  public void Execute() {
    // do something
  }
}

I have also tried this with a shared interface (not my primary goal, but I’m trying to figure this out first) so it would look like:

[Serializable]
public class MyClass : MarshalByRefObject, IPlugin {
  public void Execute() {
    // do something
  }
}

Where IPlugin is a known type in the parent application and the plugin has the appropriate reference at build time but this doesn’t seem to work either.

I’m guessing at this point that it’s not possible to load a type as dynamic across the AppDomain boundary.

Is there a way to actually get this to work?

  • 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-06T17:35:15+00:00Added an answer on June 6, 2026 at 5:35 pm

    As leppie indicated, you’ll have to implement the IDynamicMetaObjectProvider interface to wrap the proxy that’s being returned to you, and then you can use make dynamic calls on that.

    In your implementation, you’d want to take the wrapped proxy and forward all calls to the static ExecuteMessage method on the RemotingServices class, which will take your proxy, as well as an IMethodCallMessage interface implementation.

    Note that implementing the IMethodCallMessage interface is not trivial. Also, you’d have to properly interpret the IMethodReturnMessage interface implementation to get the return value, ref and out parameters correctly (if any).

    That said, it’s generally a better idea to provide an assembly that contains only an interface for the client and server to assume; if a method is changed in any way on the server side, even though the client side uses dynamic, you’d still have to change the call site to accommodate the change. At least with the interface, you get some type of compile-time check, which is always preferred to a run-time error.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.