473,473 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Passing a C# byte[] as a C++ System::Byte*

I need to call a managed C++ dll with a method interface like this:

void foo(System::Byte* i_bar);

I'm using C#, and I have a byte[] containing the data. How can I pass it?

byte[] myData = new byte[]{...};
ManagedCPPClass.foo( ??? );

Thanks,
David
Nov 15 '05 #1
1 2692
David,
I'm using C#, and I have a byte[] containing the data. How can I pass it?


unsafe {
fixed ( byte* pb = myData )
ManagedCPPClass.foo( pb );
}

Personally I'd change the MC++ method to take a byte array as
parameter instead, and handle the pinning in the C++ code instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
When I execute the following (with an OleDBDataAdapter), wanting to add a row to a visual foxpro table: myrow= datasetTarget.Tables(0).NewRow 'fill all columns here like.. row(i)= myvalue '...
1
by: u022318 | last post by:
I am writing a program with MS Visual Studio .Net 2003, which reads data from a MS SQL DB. Reading the data is fine, but when I push update, so it writes the data, it get the error message invald...
1
by: TGF | last post by:
Hello, I am calling a Filestream::Read() (i.e. fs->Read(arg1, arg2, arg3)). The problem is I have a pointer to an unsigned char block of memory and would like to fill it with the call to 'Read'....
3
by: Tim Wallace | last post by:
I have an array of bytes I read from a TcpClient. I need to pass that byte array in to the constructor of an object. My code compiles, but when run, I get a message stating: ...
0
by: EdInPhoenix | last post by:
I'm not sure where to post this, so I thought I'd start here. I need to get a .NET web service to play nice with a Java consumer. The web service passes back a byte array with an encrypted...
0
by: Johan | last post by:
Hi, I would like to pass a byte array from my activex control which is being used in a c# application, but I dont really know how. I've stumbled across VARIANTS and safearrays and such, but I'm...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
0
by: eitanyan | last post by:
I am trying to create a Java to .Net interop and the way I am doing it is by creating a C# com object and a native unmanaged c++ dll that uses JNIEnv of java. the java is loading the native c++ dll...
1
by: miller.brettm | last post by:
Hi, I'm working with an ActiveX serial component that fires an event when data is received. I need to continue to use this component because it contains the ability to do Xmodem1k an d XmodemCRC...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.