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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:57:03+00:00 2026-05-16T15:57:03+00:00

I want to load plugins in a similar way as shown here however the

  • 0

I want to load plugins in a similar way as shown here however the loaded assemblies seem not to share the same context.

Trying to solve the problem I just build a tiny spike containing two assemblies. One console app and one library. The console app contains the IPlugin interface and has no references to the Plugin dll.

I am scanning the plugin dir using a custom Registration convention:

ObjectFactory.Initialize(x => x.Scan(s =>
    {
        s.AssembliesFromPath(@"..\Plugin");
        s.With(new PluginScanner());
    }));

public void Process(Type type, Registry registry)
{
    if (!type.Name.StartsWith("P")) return;

    var instance = ObjectFactory.GetInstance(type);
    registry.For<IPlugin>().Add((IPlugin)instance);
}

Which thows an invalid cast exception saying “can not convert the plugin Type to IPlugin”.

public class P1 : IPlugin
{
    public void Start() { Console.WriteLine("Hello from P1"); }
}

Further if I just construct the instance (which works fine by the way) and try to access ObjectFactory in the plugin ObjectFactory.WhatDoIHave() shows that plugin instance and host instance don’t even share the same container instance.

Experimenting around with MEF, Structuremap and loading the assembly manually whith Assembly.Load(“Plugin”) shows if loaded with Assembly.Load it works fine. Any ideas how I can fix this to work with StructureMaps assembly scanning?

  • 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-16T15:57:04+00:00Added an answer on May 16, 2026 at 3:57 pm

    I found the solution.

    Take this structure:

    \Plugins
            \Plugin.dll
            \core.dll
    \app.exe
    \core.dll
    

    So IPlugin is defined in core.dll. My Plugin has a dependency to the core, as well as my app.
    My app loads the core.dll and loads the plugin.dll which will search for its dependency in its plugin folder. Loading core.dll a second time.

    If I get a type from Plugin.dll and try to cast it to IPlugin in the core the app tries to cast an object which is subclass of {PluginDir}Core.IPlugin to {AppDir}Core.IPlugin. This will fail because the interfaces are different ones.

    \Plugin.dll
    \app.exe
    \core.dll    
    

    This scenario will work fine because both app.exe and plugin.dll wil use the same core.dll.

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

Sidebar

Related Questions

I want to load PNG-file from resources. There is a roughly MFC-way (with CResourceStream
For jQuery template: http://api.jquery.com/category/plugins/templates/ I want to be able to dynamically load the templates
I want to load My ACL plugin to the application, and just start working
at first sorry my bad English I want load model in my plugin controller
I want to load the form fields using json data. I am using extjs
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
I want to load multiple languages to use IVONA SDK with SSML for iPhone.
I want to load multiple variables into one .mat file at the end of

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.