0

I am learning how to implement simple plugin system. I have found myself a guide on the MSDN site, yet I have encounted the problem I cannot solve (it was not written anywhere).

The image below shows how the setup looks like. MEFPlugin is the startup project (GUI), where FirstPlugin and SecondPlugin are simple DLL files that are supposed to do something. Please take a closer look at highlighted FirstPlugin.dll, that on the icon it has a blue arrow (sort of like a reference mark)

enter image description here

Now when I tried to create my own sample project, I could not figure out how to reference created dll in such a way. What I did upon building my project, is to go to Bin>Debug folder of my plugin and drag&drop file into my Visual Studio. However as you can see, it has no reference arrow on the icon. Indeed, if I do any changes to my plugin logic, it does not reflect it until I manually copy the created dll file.

enter image description here

How should I correctly reference a plugin in my project?

EDIT:

This is link for the tutorial: https://code.msdn.microsoft.com/windowsdesktop/Creating-a-simple-plugin-b6174b62

Robert J.
  • 2,631
  • 8
  • 32
  • 59
  • Plugins are usually loaded dynamically into an appdomain using reflection. If you reference the DLL in your project you can access it directly anyways without the need for a specific plugin system. Are you sure you understood the tutorial correctly? To just reference a DLL, right click on "References" and select "Add reference" – Jens Oct 26 '15 at 17:04
  • The reason why I need to do it (why I believe I need to do it) is that upon my application start I first read all the plugins that are present in the **Plugin** folder (number of plugins vary from one user to another). However when I am developing the whole solution, I want Visual Studio to automatically copy all updated DLL files, so that I can test the new functionality – Robert J. Oct 26 '15 at 17:09
  • Don't worry about the blue arrows, that means that the files are added in there as links, not the actual file. The problem though is your settings, you should not have it set to "Content", set the Build Action to "None". – Ron Beyer Oct 26 '15 at 17:12
  • Copying files into an arbitrary folder is not so easy. Look into Build scripts, or add a #If DEBUG #endif construct (https://msdn.microsoft.com/de-de/library/4y6tbswk.aspx) that adds additional folders to load while in using a DEBUG build – Jens Oct 26 '15 at 17:12
  • Ron Beyer - worked like a charm! Make it a regular answer, please. – Robert J. Oct 26 '15 at 17:14

1 Answers1

0

The blue arrow means the file is a link to an existing one, otherwise when you add files to a folder, the file is copied there. Adding as a link keeps the file in its original location and just links it to the existing file.

In order to add as a link, right click in the folder you want to add the file in, then navigate to the desired file. Before you click the "Add" button, there is a drop-down box that allows you to add as a link:

Add As Link

I think the problem that you have though is the "Build Action", if you set the Build Action to "None", that should fix the problem that you are having. For an overview of the build actions, see this stack overflow answer: What are the various "Build action" settings in Visual Studio project properties and what do they do?

Community
  • 1
  • 1
Ron Beyer
  • 11,003
  • 1
  • 19
  • 37