I have a C # .NET 3.5 project which, unfortunately, relies on a couple of VB6 ActiveX controls.
Until now, I could happily access the data containers and methods defined in ActiveX controls by simply adding a link to the controls in my project and referring to them as usual.
However, today I fell into the trap when I had to call a method that returns VBA.Collection.
My code will compile without problems, but at runtime I get the following error:
Failed to load file or assembly 'Interop.VBA, Version = 6.0.0.0, Culture = neutral, PublicKeyToken = null' or one of its dependencies. The system cannot find the specified file.
I have links to Interop.VBA (version 6.0.0.0) and Interop.VBRUN (version 6.0.0.0) in my project, any thoughts?
I canβt give a specific code, it is distributed under the NDA.
However, here is a sample code from the objectβs browser with the names changed to protect the not so innocent;)
I can reference the following properties and methods from my code:
ReturnConstants GoodMethod(); string prop1 ReturnConstants prop2
If I try to call this method, I get the error message above at runtime:
Collection BadMethod();
So, this is a method call that returns VBA.Collection, which causes the problem. These are third-party controls that I have no control over, and they will not be overwritten in .net
edit: Out of interest, I went and tried the quick dummy of the VS2010 project and worked perfectly as expected, so it seems like this could be a problem with VS2012. I saw several posts that hinted that 2012 will not correctly create transitions for VBA, so I'll go see what I can find there ...