Error: cannot convert from 'ref Scripting.Dictionary [c:\...\Interop.Scripting.dll]' to 'ref Scripting.Dictionary []'
-
Quick Q for the interop specialists among us: I have a COM object written in a VB6 legacy app. The public method I'm trying to call is something like this in VB6:
Public Function MyFunc(ByRef theDictionary As Dictionary) as Long
' ... do stuff
End FunctionThe VB6 project has a Reference to "Microsoft Scripting Runtime". In C#, I've imported this vb6 type w/ the type library importer, and have a reference to "Microsoft Scripting Runtime", ie: Interop.Scripting.dll in my C# project. When I call this class from C#, like so:
public int CallMyFunc()
{
Vb6Type vbObj = new Vb6TypeClass();Scripting.Dictionary vbDictionary = new Scripting.DictionaryClass(); ... int retVal = vbObj.MyFunc(ref vbDictionary); ....
}
I end up w/ a compiler error that doesn't make sense to me: Error 3 Argument '1': cannot convert from 'ref Scripting.Dictionary [c:\...\Interop.Scripting.dll]' to 'ref Scripting.Dictionary []' Note that it can't convert the variable vbDictionary to an array of Scripting.Dictionary. Intellisense will show the parameter type as "ref Scripting.Dictionary theDictionary", hitting F12 takes me to a function of the imported type that looks like this:
[DispId(1234)]
int MyFunc(ref Dictionary theDictionary);Any suggestions? I have the source for the VB6 and I'm actaully calling a wrapper which has the same signature. I'm about to create a custom type in vb to wrap this and avoid the drama.
-
Quick Q for the interop specialists among us: I have a COM object written in a VB6 legacy app. The public method I'm trying to call is something like this in VB6:
Public Function MyFunc(ByRef theDictionary As Dictionary) as Long
' ... do stuff
End FunctionThe VB6 project has a Reference to "Microsoft Scripting Runtime". In C#, I've imported this vb6 type w/ the type library importer, and have a reference to "Microsoft Scripting Runtime", ie: Interop.Scripting.dll in my C# project. When I call this class from C#, like so:
public int CallMyFunc()
{
Vb6Type vbObj = new Vb6TypeClass();Scripting.Dictionary vbDictionary = new Scripting.DictionaryClass(); ... int retVal = vbObj.MyFunc(ref vbDictionary); ....
}
I end up w/ a compiler error that doesn't make sense to me: Error 3 Argument '1': cannot convert from 'ref Scripting.Dictionary [c:\...\Interop.Scripting.dll]' to 'ref Scripting.Dictionary []' Note that it can't convert the variable vbDictionary to an array of Scripting.Dictionary. Intellisense will show the parameter type as "ref Scripting.Dictionary theDictionary", hitting F12 takes me to a function of the imported type that looks like this:
[DispId(1234)]
int MyFunc(ref Dictionary theDictionary);Any suggestions? I have the source for the VB6 and I'm actaully calling a wrapper which has the same signature. I'm about to create a custom type in vb to wrap this and avoid the drama.
Wes Jones wrote:
Scripting.Dictionary vbDictionary = new Scripting.DictionaryClass();
Do you need to use a
DictionaryClass
? Can you try using justScripting.Dictionary vbDictionary = new Scripting.Dictionary();
?There's nothing left in my right brain and nothing right in my left brain.