Using Ninject in .dll non executable plugin

17 views
Skip to first unread message

Rene Škarabot

unread,
May 4, 2020, 3:55:08 AM5/4/20
to ninject
Hello,

I am pretty new in dependency injection, I am developing a C# plugin application. In the main executable program, I am creating a new kernel in the main method and Ninject is working as expected.

But I am having a hard time with the implementation of Ninject into non-executable .dlls which will work as plugins for the main program. Each plugin dll is its own solution in Visual Studio. Is it possible to use Ninject in non-executable dolls, which do not have a main method, and how?

Thank you and best regards,
Rene

Assil Abdulrahim

unread,
May 4, 2020, 7:30:41 AM5/4/20
to ninject
The short answer is YES.
"Is it possible to use Ninject in non-executable dlls, which do not have a main method, and how?"
Dependency Injection is made to separate implementations from each other.
Your DLL plugins can have interfaces (expect interfaces) without any tangible classes.
but all these dlls will eventually run in one EXE, and only in that exe you will have the registration of (interface, implementation) .. where your dll will resolve whatever it needs.
Now, sometimes, you want to have the registrations in your DLL themselves ... In which case you need to expose that method to register and call it from outside i.e. from the EXE .
I hope I answered your question in a way that is clear.
Reply all
Reply to author
Forward
0 new messages