Question

I have a little problem understanding what I should do.

I have a main project MainProj.
And another project called PluginHandler who has an IPlugin interface.

What I'm trying to achieve is to "send" an object called Network from MainProj to each plugin that implement the IPlugin interface.

My problem is what type should I write in the IPlugin, because it's in a different project I can't just say Network - and I can't reference it because I need a reference to the PluginHandler in the MainProj, in order to instantiate each plugin (using reflections)

Any ideas?

Was it helpful?

Solution

You need to create a "shared library". So instead of

  • MainProj
    • Network
  • PluginHandler
    • IPlugin
  • Plugin

you should have

  • MainProj
  • PluginHandler
    • IPlugin
  • Plugin
  • Common
    • Network

So you place the Network class inside the Common project and reference this by all other projects.

OTHER TIPS

You just need to add the other project as a reference in your MainProj and then add a using statement to import that namespace into your file.

When adding a reference you can either choose a dll or just choose another project.

How to add a reference

How to add a using statement

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top