Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / October 2004

Tip: Looking for answers? Try searching our database.

Csharp calling C++ Managed code using Byte array reference

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Trev - 31 Oct 2004 13:59 GMT
I can call C++ methods using byte arrays as values but I wish to call a C++
method using a reference to an empty byte array that is then initiaised to a
set size by the c++ method and populated within the c++ mthod before
returning back to the  c# code.

E.g.

c# call

    byte[] data;
    cpp_method.getData(ref data);

c++ method signature

    int getData  (System::Byte __gc * __gc * byteArray __gc[])

However this is not allowed.

Can anybody help me in how I need to call a C++ managed method passing a
reference to a byte array that is going to be initialised in the c++ layer.

Thanks
Willy Denoyette [MVP] - 31 Oct 2004 20:49 GMT
Try this:

// CLS compliant  function taking a REF array
void GetArray( System::Byte (*bArray) __gc[])
 {
  *bArray = new System::Byte[123];
 }

Willy.

>I can call C++ methods using byte arrays as values but I wish to call a C++
> method using a reference to an empty byte array that is then initiaised to
[quoted text clipped - 20 lines]
>
> Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.