Can't instantiate a COM object written in C# from VBA (VB6 ok)
I'm going to answer my own question, hopefully to spare others the hours of tedious drudgery I have just endured.
If you get this, it is because the .NET based COM assembly can't find the .NET framework
The solution is simple. Create a file containing the following
<?xml version="1.0"?><configuration> <startup> <supportedRuntime version="v2.0.50727"/> </startup></configuration>
Call it "Excel.Exe.Config" and place it in the same directory as "EXCEL.EXE"
Problem solved!
installing the follow fix will resolve this issuehttp://www.microsoft.com/downloads/details.aspx?FamilyID=1b0bfb35-c252-43cc-8a2a-6a64d6ac4670&displaylang=en
RC1, I tested this with your code from VBScript and from within Office 2007's Excel, everything works fine.
Since your able to create the COM object from within a VB6 form we should assume that your .net framework is ok. Can you rule out issues with VBA? Can you create a .vbs file and put this in it:
Dim o As Object Set o = CreateObject("Test9.COMINT") o.Init "A", "B"
Save the file and double click it. If you get an error, then I would think there is an issue with it being registered, if you don't get an error, then I would look at Office and VBA and see if something is missing or not installed properly.
Another option is to add a reference to COM object and use early binding? I think you might need to export a typelibrary first, but you should be able to add a reference and simple new the object up.