Marshal C# String to ActiveX DLL
-
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
-
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
It always works for me, but then I always use
byval
in my function parameters. Maybe that will help.