473,811 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

byte[] as output parameter in managed C++

Hello,
I would like to know the managed C++ syntax of the following method
(defined in C#):

void temp(out byte[] byteArr).
I tried something like:
void temp([Out] byte byteArr __gc[])

But it didn't work.

Thanks,

Nov 17 '05 #1
3 1905
> Hello,
I would like to know the managed C++ syntax of the following method
(defined in C#):

void temp(out byte[] byteArr).
I tried something like:
void temp([Out] byte byteArr __gc[])


first, replace byte with Byte.

Next, the following should work:

using namespace System::Runtime ::InteropServic es;

void temp([Out] Byte (* byteArray)__gc[])

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #2
Thanks,
That did the trick for me.

How ever I'm not fimiliar with the syntax.
The syntax you've suggested:
void temp([Out] Byte (* byteArray)__gc[])

is not like:
void temp([Out] Byte __gc* byteArray __gc[])

What does (*byteArray) mean ? (looks like the syntax for function
pointers ...


Tomas Restrepo (MVP) wrote:
Hello,
I would like to know the managed C++ syntax of the following method
(defined in C#):

void temp(out byte[] byteArr).
I tried something like:
void temp([Out] byte byteArr __gc[])


first, replace byte with Byte.

Next, the following should work:

using namespace System::Runtime ::InteropServic es;

void temp([Out] Byte (* byteArray)__gc[])

--
Tomas Restrepo
to****@mvps.org


Nov 17 '05 #3
> That did the trick for me.

How ever I'm not fimiliar with the syntax.
The syntax you've suggested:
void temp([Out] Byte (* byteArray)__gc[])

is not like:
void temp([Out] Byte __gc* byteArray __gc[])

What does (*byteArray) mean ? (looks like the syntax for function
pointers ...


Nope, it is just to ensure the correct interpretation. Without the (), it
could be interpreted as an array of pointers to Byte, which is not what you
want. You need to be interpreted as a pointer to an array of Byte, which is
different :)

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #4

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

Similar topics

1
7232
by: Eric Hendriks | last post by:
// In an unmanaged DLL the following function must be called: // int VFGeneralize(const BYTE * const * features); // "features" parameter is supposed to be an array of byte arrays. // function is Marshaled as follows: static extern int VFGeneralize(byte features); In C# I have the following: // Allocate memory to store "Count" references to byte arrays
13
2165
by: Ray Z | last post by:
So far, I get the idea that if I want to use both the unmanaged and managed memory, I can not avoid memory copy. But I DO need to avoid it. I get a idea that maybe I could use "union" to convert byte to int and so on. Here is my source code, I wonder if this will work with GC? struct MyUnion {
5
4794
by: Philippe Bertrand | last post by:
Using C#, I want to send a byte array to an unmanaged function with the minimum amount of copies. The array is input only and won't be modified (its copied on the unmanaged side). I'm currently using fixed byte *. My question is: Should I be using In byte parameter instead? Ref parameter? fixed( byte *b = byte_array ) { MyUnmangedFunc2( b, byte_array.Length ); }
16
14144
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the byteArray and afterwards see the changes in C#. (if you wanna know more details: the goal is to write the content of an existing char-array in c++ precisely into the passed byteArray, so that after the function has proceded the content of the...
8
10722
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to receive a byte array as one of its parameters. The project is marked for COM interop, and that all proceeds normally. When I reference the type library in the VB6 project, and write the code to call the function that returns the byte array, it works
4
2441
by: EdInPhoenix | last post by:
Hi All, I'm not a c++ programmer, but I find myself writing an extended stored procedure to call a web service. I got this part working. I want to pass parameters through the extended proc on to the web service. The params come in through a BYTE* param in here (pData): srv_paraminfo(pSrvProc, 1, &cType, &uMaxLen, &uLen, pData, &fNull);
1
4914
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm specifiying my code: The Code used in Visual Studio: Function GetRank(ByVal ID As Integer, ByVal Comp As String, ByVal Sec As String, ByVal iDate As Date) As String 'Dim Ret As Integer
17
7263
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 to show the array data to the end user. Can I do that? How?
0
2904
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 and invokes a method in it which invokes a method on The command passed from java to .Net is a byte array and the response passed back is also a byte array the C# managed COM object which finally invokes a method on a regular C# managed dll....
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10124
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.