This project has moved and is read-only. For the latest updates, please go here.

Problem run a plugin inside the Host when controls DLl are added into plugin

Apr 14, 2014 at 1:13 PM
Edited Apr 14, 2014 at 1:19 PM
Hi Guys,
I have really tough time with WindowsFormsControlLibraries... It seems that the Host(my case Cubase but also happen within the host example from VST.Net) just cant load any assemblies out of the CUbase.Exe folder.. I read how CLR looks for assemblies and understand that, But still stuck with that...

I created simple WindowsFormsControlLibrary, built, got Dll, loaded into Tool box, It works I can drag and drop that control into my plugin... But At the moment when I wanna load such plugin into Host I get the message that it cant find the control assembly.... For core and framework assemblies it works I can run plugin when I havent them registred in GAC but my additional assemblies are just not found... I looked into the csproj file to set some differet things but still without success... It is very enoying to have to copy my DLl with controls into the folder with CUbase Executable...Have you met this ?

It is part of my Csproj with referencies and I cant find difference between Framework and core assemblies which work fine and my assebmly reference...
<Reference Include="Jacobi.Vst.Core, Version=, Culture=neutral, PublicKeyToken=fa678e13c1efc859, processorArchitecture=MSIL">
    <Reference Include="Jacobi.Vst.Framework, Version=, Culture=neutral, PublicKeyToken=fa678e13c1efc859, processorArchitecture=MSIL">
    <Reference Include="Jacobi.Vst.Interop, Version=, Culture=neutral, PublicKeyToken=fa678e13c1efc859, processorArchitecture=x86">
    <Reference Include="MyTrackBar, Version=, Culture=neutral, processorArchitecture=MSIL">
Apr 14, 2014 at 2:34 PM
VST.NET hooks into the assembly loading mechanism. It uses the folder the plugins was loaded from as a basis to satisfy additional load requests (of your dependent assemblies).
This class takes care of that:
together with this class:

Also make sure that you use the correct x86/x64 assemlbies. For managed assemblies it does not matter but the Jacobi.Vst.Interop.dll is critical that you use the correct flavor. From the text you posted it looks like you are using the x86 32-bits version. Is your Cubase also 32-bits?

Can you post the exception message with the call stack? That would give some concrete information where the error occurs.

Apr 14, 2014 at 5:33 PM
If you're still stuck, you can enable FusionLog to get more information on assembly loading failure.
Apr 14, 2014 at 8:24 PM
Edited Apr 14, 2014 at 9:07 PM
thanks, this is the log from Fusion (very handy)
*** Assembly Binder Log Entry  (14.4.2014 @ 21:07:25) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  C:\Program Files (x86)\Steinberg\Cubase 5\Cubase5.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = testControl, Version=, Culture=neutral, PublicKeyToken=null
LOG: Appbase = file:///C:/Program Files (x86)/Steinberg/Cubase 5/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
I was used to having a config file in my root of project when I was writing WebAPps, But here is no config file in the template VSTaudioPlugin... I thought that I can set this up in Csproj file and the compiler can read it from there and add into the created assembly, am I Wrong? Or where I can set this things up

It sucks, I read something on the internet and it seems that I have to keep all my asseblies used in plugin in the context of codebase of CUbase. So they have to stay in the folder Cubase 5 or in subdirectories

as written here

I can add a app.config and ad this tag
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="bin;bin2\subbin;bin3"/>
But it is still for subdirectories of application base....

Marc: I understand that two classes you posted me solve this problem for Framework, COre and Plugin Assemblies but I do not know how to use them to load my assembly as well... I thought that it just add as a private probe the current location of the plugin so that it enables to load all assemblies inside that location but it does not work for any assemblies except yours...
Apr 14, 2014 at 9:18 PM
Edited Apr 14, 2014 at 9:23 PM
For a quick fix, I suggest getting rid of app.config and putting all your assemblies in :
file:///C:/Program Files (x86)/Steinberg/Cubase 5/

Iit could work since this is the path that is resolved. I suspect Cubase loads your plugin from this startup directory.
I wonder if there is a better solution though... Maybe GacUtil ?

I think the config file you added would resolve to:
file:///C:/Program Files (x86)/Steinberg/Cubase 5/bin
file:///C:/Program Files (x86)/Steinberg/Cubase 5/bin2/subbin
file:///C:/Program Files (x86)/Steinberg/Cubase 5/bin3
Apr 14, 2014 at 9:29 PM
Edited Apr 14, 2014 at 9:47 PM
yes it is the only option right now, but it is not good because of debugging. I have my plugin in
C:\Users\asleis\Documents\Visual Studio 2012\Projects\3TMatrixPlugin\3TMatrixPlugin\bin\x86\Debug
I think that I can change build location for that to
file:///C:/Program Files (x86)/Steinberg/Cubase 5/

but it is going to be messy, as a quick fix it is going to work but it is not Ideal :-( I can attach to the process only the dll built into debug folder through Visual studio right?

I thought that this problem with referencies is a big deal only in Java world where I used to "enjoy" it pretty much but it seems to be a lot of fun in .net as well :-D
Apr 14, 2014 at 11:15 PM
Edited Apr 14, 2014 at 11:24 PM
When your plugin is running (openned) in cubase you should be able to debug in visual studio by going into menu Debug-> Attach to debugger, select Cubase in the list of programs. You dont need to change your build location, just add a copy command in the post build in project properties if you want the plugin copied to cubase directory automatically.

You can attach to any process, even on a remote machine. If the debugging symbols fail to load try copying the pdb in the executable directory. After attaching to process, you can open the Modules window in visual studio to check if your plugin debug symbols have been loaded.
Apr 15, 2014 at 2:13 AM
Ok thanks i will try, i thought that only the DLl which is loaded into cubase can be attached and that the one is in my debug folder
Apr 15, 2014 at 6:33 AM
The classes I referenced are used by the interop to load your managed plugin and any dependencies it may have - I just want to give you a look under the hood. I have put a good deal of work into getting this to work, so either you are doing something wrong or it is a bug in VST.NET. My intention was to use the plugin folder as a basis to load all dependencies from.

Again I'd like to see the error message and the call stack...

As a workaround you can also try to create a .config file for the Cubase.exe (Cubase.exe.config) and put a "vstnetProbePaths" in the appsettings that contains a ';' separated list of probe paths, these paths will be used as fallback paths for finding the correct assembly.