473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to marshal managed array to DLL.

Hi,

I'm using C# and C++ DLL. I need to send an array of unknown size at
compilation time to C++ native code. How to do this.

Example;

C#:
byte[] Image = ImageLoadFromFile(FileName); // as like the dynamic
image in the C++, for example, image loads from the file at the run
time.

C++:
void GetImage(unsigned char *Img, unsigned int size);

How to declare GetImage in C# for to recieve and read array in C++
correct?

Thanks in advise,
Eugene.

Jan 12 '07 #1
2 4000
"Ananas" <re****@gmail.comwrote in message
news:11**********************@v45g2000cwv.googlegr oups.com...
Hi,

I'm using C# and C++ DLL. I need to send an array of unknown size at
compilation time to C++ native code. How to do this.

Example;

C#:
byte[] Image = ImageLoadFromFile(FileName); // as like the dynamic
image in the C++, for example, image loads from the file at the run
time.

C++:
void GetImage(unsigned char *Img, unsigned int size);

How to declare GetImage in C# for to recieve and read array in C++
correct?
[DllImport("....")]
extern static void GetImage(byte[] img, int size);

Willy.

Jan 12 '07 #2
Thanks.

"""Willy Denoyette [MVP] ÐÉÓÁÌ(Á):
"""
"Ananas" <re****@gmail.comwrote in message
news:11**********************@v45g2000cwv.googlegr oups.com...
Hi,

I'm using C# and C++ DLL. I need to send an array of unknown size at
compilation time to C++ native code. How to do this.

Example;

C#:
byte[] Image = ImageLoadFromFile(FileName); // as like the dynamic
image in the C++, for example, image loads from the file at the run
time.

C++:
void GetImage(unsigned char *Img, unsigned int size);

How to declare GetImage in C# for to recieve and read array in C++
correct?

[DllImport("....")]
extern static void GetImage(byte[] img, int size);

Willy.
Jan 12 '07 #3

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

Similar topics

1
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...
1
by: Ken Allen | last post by:
The documentation is not clear on the exact behaviour of the Marshal.PtrToStructure method and whether it copies the contents of the IntPtr region to a new managed object or whether it creates the...
5
by: Daniel Brown | last post by:
I am coding a managed C# wrapper for an unmanaged C DLL and I am unable to marshal a structure that contains an array of structures. When executed, the following code throws an ArgumentException...
1
by: dhornyak | last post by:
I have been banging my head against the wall for a while now, and can't seem to id the problem. I've been through a ton of posts and the code doesn't seem any different. Can anybody see it? When...
0
by: Johannes Unfried | last post by:
Problem Best practice needed to marshal STL data from managed code to unmanaged code & vice vers Details managed code is written in managed C++ & accesses the unmanaged code (i.e. lives in a...
2
by: Fei Li | last post by:
Hi, After converting String* to Char*, I need to call Marshal::FreeHGlobal(). Fine. But I need pass this Char* to an unmagaed C++ class and the managed C++ class is not possible to do...
1
by: nicewenyan | last post by:
I want to pass a managed c# byte (8 bit) array into a unmanaged c++ function: extern "C" void AddData(unsigned int* data); I use P/Invoke on managed side to do the marshaling as following: ...
7
by: repekto.argosoft | last post by:
Hi, I'm working with Marshalling. I got an idea to pass an object to the Native side as a byte array i.e. as void* in terms of C. For example: I have a .NET structure Point that contains...
1
by: Christian Schmidt | last post by:
Hi all, I need to implement an unmanaged function that gets a SafeArray and hands it over to a managed function having the managed array-type. Using MarshalAs I can call unmanaged functions having...
2
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.