TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jmales
NA
5
0
Passing an array of bytes from C++ to C#
Nov 18 2004 4:51 AM
Hi All, I am trying to write a C# program to call a routine in managed C++. In the routine, the C# program passes a delegate to the managed C++. The delegate looks like this in c++: public __delegate void FoundPidDelegate ( unsigned char pData __gc[], ); My C# routine looks like this: static private void MyFoundPidFunction (byte []pData) The C++ program should call the delegate and pass it an array of bytes (or at least the address of an array of bytes). In C++ I am allocating the memory like this: unsigned char arrManaged __gc [] = new unsigned char __gc[iDataLen]; Then I call the C# delegate routine like this: m_pFoundFunc(arrManaged); When I arrive back in my C# program, the pData array only has ONE element (a correct one) and if I try to look at pData[1], I get an error. What am I doing wrong? Thanks! Josh
Reply
Answers (
5
)
Wrapping unmanaged variables from an unmanaged DLL
Offline Project....and Online Project