InvalidProgramException: Invalid IL code

Topics: Getting Started
Nov 11, 2013 at 8:05 PM
Hey all, I'm still pretty new at VST.NET and I'm trying to get it working in Unity. I'm getting the following error when trying to create a new plugin using VSTPluginContext.

InvalidProgramException: Invalid IL code in Jacobi.Vst.Interop.Host.VstPluginContext:Create (string,Jacobi.Vst.Core.Host.IVstHostCommandStub): IL_005f: call 0x0600008b

Here's my code, which is modeled after what I found in the AudioVSTToolbox, here
using UnityEngine;
using System.Collections;
using System.IO;
using Jacobi.Vst.Core;
using Jacobi.Vst.Core.Plugin;
using Jacobi.Vst.Framework;
using Jacobi.Vst.Framework.Plugin;
using Jacobi.Vst.Interop;
using Jacobi.Vst.Interop.Host;

public class VSTTest1 : MonoBehaviour {
    private string path = "C:/Users/Jake/Dropbox/Pure/Assets/Plugins/VST Plugins/TAL-Reverb-2";
    void Start ()
        HostCommandStub host = new HostCommandStub();
        host.Directory = path;
        VstPluginContext pluginContext = VstPluginContext.Create(path, host);
I know my namespaces are a bit excessive, this isn't for a release build :p

Thanks for any insight or help you can give!
Nov 11, 2013 at 8:56 PM
Man your exceptions are deep o_O
Guess it's mono going down to IL.
It's a runtime exception right? And you get it both into your debug and release build?
Anyway, your sample differs quite a lot from my host.

First my class implement the host interface and is disposabe:
public class VSTTest1 : IVstHost, IDisposable

Than I initialize my plugin object with my host class object:
HostCommandStub host = new HostCommandStub(this);

I don't know what 'host.Directory' stands for, I don't use it and don't have the source code documentation on hand right now.
Can you enlighten me on this Property Mark?

The 'path' you give seems wrong (assuming it's not a file without extension), you need to give the path to the DLL file, not a directory.
Nov 12, 2013 at 2:51 PM
I suspect that mono does not like the IL generated by the C++ CLI extensions. Never tested VST.NET with mono - it's not supported...

@Yurk: There is no Directory property in VST.NET - thats custom. Probably to implement the GetDirectory() method on the host command stub...?
Nov 13, 2013 at 4:33 AM
I see how you're doing it YuryK, that makes a bit more sense. I'm just starting to get my head around implementing things in this manner. Jacobi is correct about the Directory property, which I borrowed from the AudioVSTToolbox code I mentioned above.

I was unaware different editors would compile things in different ways. I'm going to see if I can connect Visual Studio with Unity.

Thanks very much for your quick replies! I will post my progress on this as it comes so others can learn.
Nov 13, 2013 at 5:36 AM
I didn't specify it explicitely but I'm also doubtful Vst.Net would run properly if you're not using Microsoft tools. It's pretty surprising it managed to compile at all.