I am referencing a COM dll file using CodeDom. The function within the dll file has parameters as follows:
Public Function Foo(fooString As String, fooByte() As Byte)
End Function
When this dll file is referenced directly by Visual Studio (Not using CodeDom), I call this function as follows – and the solution builds with no problems:
Byte[] b = File.ReadAllBytes("Test.exe");
DllName.DllClass dll_obj_reference = new DllName.DllClass();
dll_obj_reference.Foo("data", b);
NOTE:
Although I am sending a byte array to the function (as requested by VB6), Visual Studio is actually asking for type System.Array. For whatever reason, the solution still builds fine, and I am able to call the function Foo with no problems at all.
However, I am not so lucky when doing this all through CodeDom. I add the interop.DllName as a reference to the generated project, and I call just the same way. This time, though, CodeDom spits back an error saying that it cannot convert type byte[] to type ref System.Array.
So, my question – finally:
How can I convert the byte array shown above to type System.Array? I cannot find any articles online.
Thank you for any help!
If it wants an array passed by reference, you’d do: