Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Error: cannot convert from 'ref Scripting.Dictionary [c:\...\Interop.Scripting.dll]' to 'ref Scripting.Dictionary []'

Error: cannot convert from 'ref Scripting.Dictionary [c:\...\Interop.Scripting.dll]' to 'ref Scripting.Dictionary []'

Scheduled Pinned Locked Moved C#
comcsharpvisual-studiodata-structures
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wes Jones
    wrote on last edited by
    #1

    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 Function

    The 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.

    A 1 Reply Last reply
    0
    • W Wes Jones

      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 Function

      The 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.

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Wes Jones wrote:

      Scripting.Dictionary vbDictionary = new Scripting.DictionaryClass();

      Do you need to use a DictionaryClass? Can you try using just Scripting.Dictionary vbDictionary = new Scripting.Dictionary(); ?

      There's nothing left in my right brain and nothing right in my left brain.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups