Code Monkey home page Code Monkey logo

Comments (6)

natemcmaster avatar natemcmaster commented on September 5, 2024

There are two facade projects in your repro. I'm not exactly sure what I'm looking for.

from dotnetcoreplugins.

godrose avatar godrose commented on September 5, 2024

@natemcmaster You're right. Use Samples.Specifications as it's easily reproduced there

from dotnetcoreplugins.

natemcmaster avatar natemcmaster commented on September 5, 2024

I read the code and I'm still not 100% I understand what you're trying to do, but it appears to me that at least one problem is that you're creating a unique assembly loader per .dll here: https://github.com/godrose/netcore-load/blob/b09327732a891b174b83e9ef8e6c453a56abfc3f/Samples.Specifications.Server.Facade/Startup.cs#L26-L29

I think there may be a general misunderstanding here of how PluginLoader is supposed to be used. Generally, each plugin should be in a directory of its own with the plugin's dependency .dll's in that same directory. Easiest way to prepare a plugin is with dotnet publish. See https://github.com/natemcmaster/DotNetCorePlugins#the-host for a more detailed description.

from dotnetcoreplugins.

godrose avatar godrose commented on September 5, 2024

@natemcmaster
So the general idea in my example is to have all plugins compiling in the same directory. It is the solution configuration which will decide whether the specific plugin is eventually built. This is useful for the cases where I would like to substitute implementations of a particular interface and test the app behavior.
I examined the example you provided within the link. It states that each assembly file indeed has its own loader

var loader = PluginLoader.CreateFromAssemblyFile(
                    pluginDll,
                    sharedTypes: new [] { typeof(IPlugin) });
                loaders.Add(loader);

So I don't really see how it's different from what I'm doing.
The question here is what happens if you use

var loader = PluginLoader.CreateFromAssemblyFile(
                    pluginDll,
                    config => config.PreferSharedTypes = true);
                loaders.Add(loader);

instead and remove the explicit reference to the project containing the IPlugin interface.
Will it still work? Should it?

from dotnetcoreplugins.

natemcmaster avatar natemcmaster commented on September 5, 2024

The distinction I was trying to make was that 1 plugin = 1 plugin loader. There might be multiple assemblies per plugin, but you should still only use 1 instance of PluginLoader. The assembly you pass to PluginLoader is the "entry" assembly, also called the "default" assembly. All dependencies of the default assembly will be found and loaded by PluginLoader. Normally, the dependencies of the plugin sit in a directory next to the default assembly.

Because you are sharing a common directory and creating multiple loaders from the same directory, you might have multiple instances of Samples.Specifications.Server.Domain.dll loaded. PreferSharedTypes only handles sharing between the host and the plugin, not between multiple plugins, so this might be why
you're code is having trouble finding implementations of IWarehouseRepository.

from dotnetcoreplugins.

no-response avatar no-response commented on September 5, 2024

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

from dotnetcoreplugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.