0

I have to continue the C# project of someone else, but I can't talk to him.

The main program of NameSpace A uses DLLs with NameSpaces B C D...

This main program loads the plugin DLLs at runtime, these DLLs must access NameSpaces A B C D...

But the problem is that the DLLs can only access the NameSpace A !

The plugins have a reference to the main exe.

What is very weird is that the already compiled exe (last version) I got from the main program, does have reference in the Object Browser of the plugin DLL for project NameSpaces A B C D, but when I compile the main program exe myself the DLL can only see the NameSpace A!

I have the source of all projects of all NameSpaces.

Any help would be warmly welcomed, this is driving me nuts !

kapa
  • 77,694
  • 21
  • 158
  • 175
Anadrol
  • 193
  • 3
  • Try to build first all projects of all namesapaces after that remove the its reference to your main project. Build main project and reference all projects namespace and rebuild it again. – BizApps Sep 06 '11 at 02:28

1 Answers1

2

...these plugin DLLs must access NameSpaces A B C D

The plugins have a reference to the main exe

Maybe there is missing information, or I am lacking sleep, but this sure seems like a strange "plugin model." Unfortunately, without knowing more, probably alot more, I don't know how to help your current situation.

That said, I would highly recommend considering re-architecting your plugins. Either:

  1. Make them part of the actual project or;
  2. Convert them to a more traditional plugin model.

If you go with Door #2, this Application Block article covers what I would consider a traditional plugin model and would probably make your life much easier if you adopted it.

Edit: I just realized my answer was probably too brief and didn't explain what I meant by "traditional plugin model".

Plugins shouldn't be referencing your application directly, nor should it require a rebuild or redeployment to use them. Typically you would define an interface in one project (sometimes referred to as a Separated Interface), but implement it separately. In other words, the plugin can know about the core library that contains the interface, but not have to know about the main executable that uses it.

So in practice, you define an interface in your core library that defines the methods that the application requires from the plugin. You then code your main application against that interface. Then during the runtime initialization of your main application, you can load the assemblies that contain the plugin classes and instantiate the plugin, or even initialize it to a test class during development. There are many examples out there on how to do this, and there are a few questions on SO about this as well.

Community
  • 1
  • 1
Paul Walls
  • 5,884
  • 2
  • 22
  • 23
  • Thank you VERY MUCH ! I was able to make everything work, I had to reference the same DLLs as the main exe, I did just point to the output directory for the build. Very strangely it didn't work before. – Anadrol Sep 06 '11 at 03:31
  • Not sure which part helped, but I'm glad you got it working! Feel free to mark this as the answer. – Paul Walls Sep 06 '11 at 03:40
  • 1
    +1 for good answer, regardless of whether the OP used it or not :) – Adam Sills Sep 06 '11 at 03:58