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

Problems with VST.NET and Visual C# Express 2010

Jul 1, 2010 at 7:01 AM
Edited Jul 1, 2010 at 7:03 AM
I'm trying to write a simple VST host using VS C# Express 2010. I don't own the full studio because it's a bit pricey -- I'm trying to get away with just using the free Express editions. I realize that's asking for trouble, but I'm trying for it anyway!

Here's what I did:

1) Created a new project which referenced the Release versions of the Core, Framework, and Interop binaries available for download from the site.
2) Copied a bunch of code from the VST host sample (specifically, the OpenPlugin function, the HostCmdStub_PluginCalled function, and the entirety of HostCommandStub.cs). I was hoping to just load a plugin as a first step.

When running the application, I get the following error:

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

This seems self-explanatory (ish). It would appear as if the dlls were built against an older version of the .NET framework. I'd guess VS2008 because that seems to be what's recommended. This implied to me that I would need to rebuild the Core, Framework, and Interop dlls from source.

This was an immediate problem because the source code solution contains references to multiple types of projects (.csproj, .vcproj). The Express edition won't allow me to open a single solution containing multiple types of projects - I can load the Interop vcproj into Visual C++ Express 2010 and the Core and Framework into Visual C# 2010, but I can't load both at once. After some wrangling, I created two separate solutions -- one for the C# stuff and another for the C++ Interop. I was able to successfully compile the Core and Framework dlls. I couldn't seem to get a Debug build to go, but that's the least of my worries right now.

So then I moved on to Interop. When I try to build the project I get literally thousands of errors. It seems like it's not properly recognizing the required Core and Framework stuff. Here's the first error I receive:

...\code\jacobi.vst.interop\plugin\HostCommandStub.h(11): error C3083: 'Core': the symbol to the left of a '::' must be a type

That implies to me that it's not recognizing the namespaces exposed in the Core and Framework dlls. I tried to add the following using statements to include those references in the C++ project:

#using <Jacobi.Vst.Core.dll>
#using <Jacobi.Vst.Framework.dll>

Depending on where I place the using statements, I get different errors. I tried placing them just below #include <stddef.h> in stdafx.h hoping that would apply it across the files. I get the error:

...\code\jacobi.vst.interop\stdafx.h(15): fatal error C1190: managed targeted code requires a '/clr' option

Now I checked the project settings, and /clr is turned on already, so this error makes no sense to me. That's where I'm stuck -- trying to build the Interop dll to reference in my actual project so that I don't get the version mismatch. Phew!

If you stuck with me all this way, do you have any suggestions?!

Thanks in advance for any help you can provide!

Jul 1, 2010 at 10:31 AM
Edited Jul 1, 2010 at 10:32 AM

I dont have VS2010 C++ Express available as I write this, but you can try to find a tab in the project properties of the C++ project where the (managed) references are listed. My guess is that it cannot find the references listed there (Jacobi.Vst.Core and System assemblies etc.). Perhaps you can re-add the Jacobi.Vst.Core reference and point it to your own (VS2010/4.0) version?

From what I know, the problem is that mixed/hybrid assemblies (Interop contains both native C++ and managed C++) are automatically loaded into the newest CLR on the machine. Apperently the new 4.0 CLR is not quite compatible with the 2.0 version that is targeted by the Interop assembly. Not sure if you can fix this with the standard <runtime> conifg in your app...??

Hope it helps.

BTW: The code in the VstHost sample is not production code ;-). Its fine to get a handle on how things work, but its a simplification on what a real host has to implement.

Aug 25, 2011 at 6:00 PM

FYI I was having the same issue using pre-built Vst.Net binaries with VS2010 Pro, it's not a problem with Visual Studio Express:

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

Marc, you're quite right it can be fixed using .Net configuration. I fixed it by adding a .config file to my startup project with the same name as the executable plus .config (e.g. "MyApp.exe.config"), setting it's properties to 'Copy if newer' (or 'Copy always') and adding the following to the XML under <configuration>:

  <startup useLegacyV2RuntimeActivationPolicy="true" >

This was based on MSDN info:

Seems to be working so far, I have successfully created a plugin context at runtime. Hope this helps other VS2010 users who want to link against public binaries of Vst.Net and don't want to have to compile source.