none
Manage byte array C++ DLL to C# (Need Help) RRS feed

  • Question

  • I have a manage C++ DLL which I am calling from C#.  What I want to do is access

    blob information held within a C++ managed object by a C# application.

     

    I have tried defining the blob data in many ways such as:

     

    C++

     

    Code Snippet
    array<Byte^>^  blob;
     
    or
     
    byte*             blob;

     

    etc.

     

     

    I am very new to .NET, C# and to Microsoft C++, so I am a little lost with managed objects.

     

    What is the best way to do this task? 

     

    How should the byte array be defined in C++? C#?

     

    thanks

    -darryl

    Friday, February 22, 2008 9:50 PM

Answers

  • Use:

    array<Byte>^  blob;

     

    note the absence of the 'hat' on Byte - it doesn't get it since it's a value type.

     

    Saturday, February 23, 2008 4:03 PM

All replies

  • Hello...

    My guess is that you can use Marshal Class and the Copy method.

    Marshal.Copy(IntPtr,Byte[], Int32, Int32).

    Here you have an example and the definition:

    http://msdn2.microsoft.com/en-us/library/ms146631.aspx

     

    Hope it helps!

    Saturday, February 23, 2008 10:09 AM
  • Use:

    array<Byte>^  blob;

     

    note the absence of the 'hat' on Byte - it doesn't get it since it's a value type.

     

    Saturday, February 23, 2008 4:03 PM
  • Thanks for the quick answer.  It didn't answer all of my questions, but did put

    me on the path to answer them myself.  You have saved me a great deal of

    time.  Thank you very much!

     

    -darryl DE WA1GON

     

    Saturday, February 23, 2008 5:54 PM