Third-party .dll in dynamic plugins (flash card)

Hey all,

After struggling for a bit to get a dynamic plugin to compile with a third party .dll, I thought the topic needed a little dedicated post as a bottle to the sea ready for anyone stuck on the matter in the future (including myself).

So here is a little summary/memo from info I found scattered across other threads, or more general c# facts:

  1. x86/x64: first off ensure the dll has been compiled for the same architecture than the vvvv.exe you’re running. If you don’t have the info from where you got the file from, unfortunately it’s not as easy as Right-Click>Properties. Here are a few differents methods/tools/tricks to find out.

  2. if it’s a managed dll (i.e. compiled from C#):

  • add the dll to the plugin’s ./bin/Dynamic folder. Do not mess with vvvv root folder (if you were tempted to paste the dll alongside vvvv.exe for example), and rather keep things contained and portable, inside your plugin own resources, as suggested.

  • with your dynamic plugin IDE open, press Ctl-J to pop the Project Manager. Drag your .dll file under References, and just add it to the other usings at the top of your code:
    using myManagedDll;

  • you’re all set!

  1. if it’s an unmanaged dll (i.e. compiled from C++): things are not that easy.
  • add the dll to the plugin’s ./bin/Dynamic folder, like above.

  • include the dll in your usings:
    using myUnmanagedDll;

  • this time do not link the dll in the References; that would through an error like “Cannot open metadata file” or similar.

  • to access any of the dll’s functions you need to add a custom wrapper, i.e. another .cs file that will manually bridge the dll content with the plugin. For that you will have to use dllimport extensively, to create an entry point for each function (see examples on msdn and dotnetperls as pointed by @tonfilm in another thread).
    This is the most painful, but you will easily find additional resources/examples on that across the internets.

  • add this file to the Project Manager (Ctl-J) by right-clicking the plugin root (MyPlugin.csproj) then Add > Existing File. Now you’re good!

Voilà!
Here’s the 101, probably just enough to give the basic tracks to anyone stuck on these questions some day!

That’s the first time I have to go through this process myself, and following the above everything seems fine for me here, but in case I said anything wrong/incomplete/unclear, anyone of you more familiar with the subject is very welcome to correct me or add his 2 cents!

T

3 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.