I have an Excel VBA module calling a C# COM dll.
Sometimes, I get a type mismatch when I step through the debugger in VBA, when I initialize a COM object as follows.
If (IsEmpty(cm)) Then
Set cm = CreateObje开发者_开发技巧ct("aimd.CMAdaptor")
End If
I can add a breakpoint in the VBA and add a watch to the cm variable, and see the type doesn't match what I instantiated. The type is for a property inside the object I'm trying to create. The object pointed to was clearly created by my "aimd.CMAdaptor" object I instantiated, I just don't get the root object I specify, only the child.
Since this is a COM object, I'm wondering if my updates could be using mismatched regasm data or something that causes it to look for the object in the wrong place. I am constantly rebuilding it for debugging, and adding it to an installer that calls regasm as a build action.
turned out to be a dumb mistake... I was copying the attributes that allow you to select the name of a class as seen on the VBA side...
[ProgId("aimd.CMAdaptor")]
this was located in two different classes. Apparently, is no complaint when you do this. I'm not sure why it picked one over the other, but after updating the incorrect attribute, everything works fine.
精彩评论