VST3PluginTestHost provides misbehaved COM interface to IPluginBase.initialize()

I’m in the process of implementing a C# wrapper for parts of the VST3 sdk, and I came across some odd behavior with VST3PluginTestHost. The IUnknown pointer passed to my code through the IPluginBase.initialize() method doesn’t show the correct COM behavior. I can reproduce the problem with the following procedure:

  1. Call QueryInterface on the passed IUnknown and get a IHostApplication pointer.
  2. Call QueryInterface on the on the new IHostApplication pointer and get an IUnknown pointer.
  3. A subsequent call to QueryInterface on the new IUnknown pointer to get IHostApplication again will fail with E_NOINTERFACE returned.

The expected behavior is that you should be able to query any interface on the same object to get any other interface on that object. I realize this example is a little contrived, but the .Net interop runtime caches COM wrappers based on their IUnknown pointer. In order for me to successfully wrap the unmanaged IHostApplication, I need to be able to get back to the IHostApplication interface from that object’s IUnknown (which is not working properly).

Loading the plugin in Bitwig works as expected (though it is much harder to debug against since VSTs are hosted in different processes on demand).