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. How to marshal string array from C# to VB?

How to marshal string array from C# to VB?

Scheduled Pinned Locked Moved C#
helpcsharpcomdata-structurestutorial
3 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.
  • N Offline
    N Offline
    nicolus
    wrote on last edited by
    #1

    Hi i am writing a C# class library which i want to use in my VB Client So i wrote class like this [Guid("0AA209CD-D713-4336-8804-F7D4888F58BD")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown )] [ComVisible(true)] public interface IClass1 { void Temp1([MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr )] String[] IDs,int size); } [Guid("CCDAD140-DD55-4047-A925-A1B539396A01")] [ComVisible(true)] [ProgId("CommonCatalogue.Class1")] public class Class1:IClass1 { public void Temp1([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] String[] IDs, int size) { string TempDate = "dfdf"; } } but when i referenced this library (.tlb) in VB the temp method singnature coming as Temp1(IDs As String, size As Long) i am unable to fix this. Please can any one help me in figuring out this.

    O 1 Reply Last reply
    0
    • N nicolus

      Hi i am writing a C# class library which i want to use in my VB Client So i wrote class like this [Guid("0AA209CD-D713-4336-8804-F7D4888F58BD")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown )] [ComVisible(true)] public interface IClass1 { void Temp1([MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr )] String[] IDs,int size); } [Guid("CCDAD140-DD55-4047-A925-A1B539396A01")] [ComVisible(true)] [ProgId("CommonCatalogue.Class1")] public class Class1:IClass1 { public void Temp1([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] String[] IDs, int size) { string TempDate = "dfdf"; } } but when i referenced this library (.tlb) in VB the temp method singnature coming as Temp1(IDs As String, size As Long) i am unable to fix this. Please can any one help me in figuring out this.

      O Offline
      O Offline
      oobimoo
      wrote on last edited by
      #2

      As far as i know, vb uses the SafeArray (UnmanagedType enumeration[^])

      N 1 Reply Last reply
      0
      • O oobimoo

        As far as i know, vb uses the SafeArray (UnmanagedType enumeration[^])

        N Offline
        N Offline
        nicolus
        wrote on last edited by
        #3

        Thanks for the response. Ya using ref in the method's declaration of C# we can get the correct syntax in VB but is there any other way which does not require any ref in the method declaration.

        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