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. .NET (Core and Framework)
  4. Marshal C# String to ActiveX DLL

Marshal C# String to ActiveX DLL

Scheduled Pinned Locked Moved .NET (Core and Framework)
questioncsharpvisual-studiocomhelp
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.
  • R Offline
    R Offline
    rgondzur
    wrote on last edited by
    #1

    I have an VB ActiveX DLL with a function the receives a string parameter. I want to call this function from C#. I made a reference to the DLL in my VS 2003 project. DLL Function -------------- public function ShowMsg (strIn as String) msgbox strIn end function C# Function Call ------------------ string str1 = "ABCD"; Class7 s = new Class7Class(); s.ShowMsg(str1); When I call the function from C#, I get an error: Argument '1': cannot convert from 'byte[]' to 'ref string' How do I marshal a C# string to an ActiveX DLL string? Thanks, Rg

    S 1 Reply Last reply
    0
    • R rgondzur

      I have an VB ActiveX DLL with a function the receives a string parameter. I want to call this function from C#. I made a reference to the DLL in my VS 2003 project. DLL Function -------------- public function ShowMsg (strIn as String) msgbox strIn end function C# Function Call ------------------ string str1 = "ABCD"; Class7 s = new Class7Class(); s.ShowMsg(str1); When I call the function from C#, I get an error: Argument '1': cannot convert from 'byte[]' to 'ref string' How do I marshal a C# string to an ActiveX DLL string? Thanks, Rg

      S Offline
      S Offline
      Steven Campbell
      wrote on last edited by
      #2

      It always works for me, but then I always use byval in my function parameters. Maybe that will help.


      my blog

      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