marshalling

Blittable Value Types

Here is a list of blittable types. It contains Int32 and Int64. But I don't see just plain "int" on the list. How does C# treat the plain "int" type? Does it just get replaced with Int32 or Int64 depending on the system? Or is there a subtle difference? Will using "int" ever cause a performance hit for marshalling? ...

Error when starting an activity

I'm starting an activity when a button is pressed, and normally (in other apps) haven't had an issue. But when I press the button in this app, I get an "unable to marshal value" error. Exact(ish) error from LogCat: 03-22 02:49:02.883: WARN/System.err(252): java.lang.RuntimeException: Parcel: unable to marshal value {CLASSNA...

Python XML + Java XML interoperability.

Hello. I need a recommendation for a pythonic library that can marshall python objects to XML(let it be a file). I need to be able read that XML later on with Java (JAXB) and unmarshall it. I know JAXB has some issues that makes it not play nice with .NET XML libraries so a recommendation on something that actually works would be great. ...

SWIG: C++ to C# ... Arrays and new objects

I have asked a similar question somewhere else, but I still cannot find a good answer (see http://stackoverflow.com/questions/2479764/swig-c-to-c-pointer-to-pointer-marshalling ). First answer did comment on typemap, but actual error message (yes, it is a memory issue, but it is because P/Invoke is not marshalling properly) I'm currentl...

How do I marshal a pointer to an array of pointers to structures?

I have a C function with the following signature: int my_function(int n, struct player **players) players is a pointer to an array of pointers to struct player objects. n is the number of pointers in the array. The function does not modify the array nor the contents of the structures, and it does not retain any pointers after return...

Most efficient way to send images across processes

Goal Pass images generated by one process efficiently and at very high speed to another process. The two processes run on the same machine and on the same desktop. The operating system may be WinXP, Vista and Win7. Detailed description The first process is solely for controlling the communication with a device which produces the image...

Fastest way to access VB6 String in C#

I am using COM Interop. I have a call in VB6 which returns a string of roughly 13000 chars. If I execute the call in pure VB6 it takes about 800ms to execute. If I execute it via c# and COM Interop it takes about 8 seconds. I'm assuming the delay is caused by marshaling. If I am correct about marshaling, I'd be grateful if someone coul...

Greyscale Image from YUV420p data

From what I have read on the internet the Y value is the luminance value and can be used to create a grey scale image. The following link: http://www.bobpowell.net/grayscale.htm, has some C# code on working out the luminance of a bitmap image : { Bitmap bm = new Bitmap(source.Width,source.Height); for(int y=0;y<bm.Height;y++) ...

Marshal struct to unmanaged array

I have a C# struct to represent a cartesian vector, something like this: public struct Vector { private double x; private double y; private double z; //Some properties/methods } Now I have an unmanaged C dll that I need to call with P/Invoke. Some methods expect a double[3] parameter. The unmanaged C signat...

Using Marshal.Copy correctly

I have a working wrapper class for Dallmeier camera devices, It contains a callback method to receive the current YUV image. See details http://stackoverflow.com/questions/2444687/c-wrapper-for-array-of-three-pointers. I have a button on my form that gets the YUV Image. The callback returns 'yuvData' which is an array of three pointers ...

What is the best way to marshal a char array function argument?

Let say that given the following signature in LegacyLib.dll: int Login(SysInst *inst, char username[8], char password[6]); The simple way to marshal this function in C# would be: [DllImport("LegacyLib.dll", CharSet=CharSet.Ansi)] public static extern int Login(ref SysInst inst, string username, string password); The problem of doin...

DllImport and char*

I have a method I want to import from a DLL and it has a signature of: BOOL GetDriveLetter(OUT char* DriveLetter) I've tried [DllImport("mydll.dll")] public static extern bool GetDriveLetter(byte[] DriveLetter); and [DllImport("mydll.dll")] public static extern bool GetDriveLetter(StringBuilder DriveLetter); but...

How do i transfer this unmanaged code from asp to asp.net 2/mvc?

hi guys, i'm a newbie to ASP.net interop features, so what i have right here is some unmanaged dll that i need to call from my asp.net mvc app. the dll name is CTSerialNumChecksum.dll. i can easily call the dll from asp using just those two lines below and from my trusty response. write everything is working fine. set CheckSumObj = Ser...

Marshaling an array of IntPtrs in C#

From safe, managed code in C#, I would like to call a function in a C API that receives an array of pointers (void**). I have the corresponding managed array of IntPtr objects, but the Marshal methods advertised in the documentation at MSDN do not seem sufficient to provide an IntPtr to an unmanaged block of memory with the correct cont...

Can JAXB Incrementally Marshall An Object?

I've got a fairly simple, but potentially large structure to serialize. Basically the structure of the XML will be: <simple_wrapper> <main_object_type> <sub_objects> </main_object_type> ... main_object_type repeats up to 5,000 times </simple_wrapper> The main_object_type can have a significant amount of data. On my f...

Exposing a C++ API to C#

So what I have is a C++ API contained within a *.dll and I want to use a C# application to call methods within the API. So far I have created a C++ / CLR project that includes the native C++ API and managed to create a "bridge" class that looks a bit like the following: // ManagedBridge.h #include <CoreAPI.h> using namespace __CORE_API...

Is marshaling/ serialization in PHP as simple as serialize($var) ?

here's a definition of marshaling from Wikipedia: In computer science, marshalling (similar to serialization) is the process of transforming the memory representation of an object to a data format suitable for storage or transmission. It is typically used when data must be moved between different parts of a computer pro...

Marshal.PtrToStructure (and back again) and generic solution for endianness swapping

I have a system where a remote agent sends serialized structures (from an embedded C system) for me to read and store via IP/UDP. In some cases I need to send back the same structure types. I thought I had a nice setup using Marshal.PtrToStructure (receive) and Marshal.StructureToPtr (send). However, a small gotcha is that the network bi...

C#: Object with custom marshaller not containing data after PInvoke call

I am having a problem with PInvoking some WinAPI functions that accept WAVEFORMATEX structures as parameters. Since the length of the WAVEFORMATEX structure can vary, I implemented a WaveFormatEX class that is marshalled by a custom marshaller class (which implements ICustmoMarshaller). This is following an example provided by Aaron Lerc...

Marshalling to a native library in C#

I'm having trouble calling functions of a native library from within managed C# code. I am developing for the 3.5 compact framework (Windows Mobile 6.x) just in case this would make any difference. I am working with the waveIn* functions from coredll.dll (these are in winmm.dll in regular Windows I believe). This is what I came up with:...