marshalling

Precise definition of the term 'marshalling'.

In the .NET world, does marshalling mean just the preparation of an object/data for transfer across some boundary or over a wire OR does it mean the preparation and transfer across a boundary or over a wire. And what does to marshal a call mean. Does it mean just the packaging of the call for "transfer" over a context boundary or is it ...

Marshalling a Linked List

Apologies for duplicate posting. Hi I am having trouble marshalling a linked list from a DLL. ------C++ Structure and Function-------- struct localeInfo { WCHAR countryName[BUFFER_SIZE]; WCHAR localeName[BUFFER_SIZE]; localeInfo *next; } int GetSystemLocales(localeInfo **ppList); -----------C# Declarations----------- ...

How to annotate a member of type collection in jaxb

I have successfully marshaled the following class @XmlRootElement(name = "Field") private static class MyField { @XmlAttribute(name = "Name") String name; @XmlElement(name = "Size") int size; ....} Now I want to have my container class to hold multiple instances of Field, so I declared a class in the followi...

Marshal Unmanaged struct to managed code using c#

Hi experts, I need to process the bytes[] when i get from external application. The external application is also done in c# and they send the bytes thru UDP. They are sending the bytes converted from struct which is stated below : public struct DISPATCH_MESSAGE { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public c...

C# DLL extern prototype help

I have a C DLL with an export that looks like the following: __declspec(dllexport) int Function( char *password, unsigned char *ssid, int ssidlength, unsigned char *output) { On the C# side, I'm using this as follows: [DllImport("myDLL.dll", SetLastError = true)] protected static extern int Function( [MarshalAs(Un...

Read/Write on protected memory exception thrown (.net)

I am being told by an exception that's being thrown in the last line, that I'm trying to read/write on protected memory. What am I doing wrong here? Thanks int count = (int)WinApi.SendMessage(_chatHwnd, WinApi.LB_GETCOUNT, 0, 0); Debug.WriteLine("count=" + count); StringBuilder sb = new StringBuilder(count * 20); for (in...

How to get the GIT in Delphi 7?

I'm trying to get the Global Interface Table by using the following code (Delphi): uses Comobj, ActiveX; var cGIT : IGlobalInterfaceTable = NIL; const CLSID_StdGlobalInterfaceTable: TGUID = '{00000146-0000-0000-C000-000000000046}'; function GIT : IGlobalInterfaceTable; begin if (cGIT = NIL) then OleCheck (CoCreateInsta...

Convert array of structs to IntPtr

I am trying to convert an array of the RECT structure (given below) into an IntPtr, so I can send the pointer using PostMessage to another application. [StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left; public int Top; public int Right; public int Bottom; // lots of functions snipped here } ...

NUL characters from Marshal.Copy in C#.

I have the following method defined: internal string GetInformation(string recordInformation) { int bufferSize = GetBufferSize(recordInformation); string outputRecord; IntPtr output = Marshal.AllocHGlobal(bufferSize); try { _returnCode = UnmanagedMethod(recordInformation, output, recordInformation.Length); ...

Non-type template parameter... that's a template! (C++)

I'm basically looking to generate a wrapper for a generic C function without having to manually specify the types. So I have a callback with a fixed prototype but I'm going to need to do some special code in the wrapper based on the type of the wrapped function... So basically I'm thinking about using a static method in a class template ...

C# to unmanaged C++

I have created 2 structures in my C# code : [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class RollInformationCSharp { [MarshalAs(UnmanagedType.R8)] public double rollDiameter; [MarshalAs(UnmanagedType.R8)] public double initialRoughn...

C#: Pointer to the struct inside the struct.

I am trying to use marshalling in C#. In C++ I have a this struct: struct aiScene { unsigned int mFlags; C_STRUCT aiNode* mRootNode; unsigned int mNumMeshes; C_STRUCT aiMesh** mMeshes; unsigned int mNumMaterials; C_STRUCT aiMaterial** mMaterials; unsigned int mNumAnimations; C_STRUCT aiAnimation** mAnim...

How do I marshall a recursive struct to c sharp?

Hi, I have an unmanaged struct I'd like to marshal to c sharp that looks basically like this: struct MyStruct{ /* ... some stuff ... */ int numChilds; MyStruct *childs; } I believe that I have to write a custom marshaller but I'm not sure on how to proceed. ...

How to suppress compiler warnings from the use of COM references in a .NET project

We're using the Windows COM+ Services Type Library (located at C:\Windows\system32\COMSVCS.dll) to track COM+ processes on a remote machine using a service that is written in C# 3.0/.NET 3.5. The problem that I am encountering is that I am getting a whole slew of warnings from the compiler that look something like the following: At l...

Enable to call C dll in VB.net Code

Hi, I am running into a problem which I am using C Dll into my VB.net code. I have .H file which shows implementation of this DLL in C language. This .H file contains many structures and unions that contain variable of some structures type. There is a main structure which contains the pointers to these structures and unions and finally a...

VB.net Marshalling Error

Hi, I have to create an array of structure type in VB.net. but I am getting error while marshalling this error. I have to pass this array of structure type in to Dll function. Code: Structure declaration: <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _ Public Structure dx_entry <MarshalAs(UnmanagedType.ByValT...

How do I ignore a field size in a struct using Marshal.SizeOf?

Is there a way to ignore a field in the calculated of the struct size using Marshal.SizeOf Ex: public struct Message { public ushort X; public ushort Y; // Ignore this field in the calculation } int size = Marshal.SizeOf(typeof(Message)); Right now size is 4. I want the size to be 2. Is there a way to do this? ...

Marshalling a class intance's pointer between C++ and C#

I have an ActiveX control (written in C++) and reference it's RCW assemblies (created by aximp.exe) from a C# project. In the C++ code implementing the Ax control, I have a class implementing an interface which is exposed as a property of the Ax control. Looking at the generated RCW assemblies, I see the interface. And I can attempt t...

Marshalling Issues

I have a C++ DLL that interacts with a card reader. It requires a pointer to a data struct, which isn't a problem to do. However, when trying to interact with the DLL in C# I'm getting all kinds of problems. Errors writing to protected memory, the application just shutting down after executing the getData command, etc. Here's what we...

How to marshal a variable sized array of structs? C# and C++ interop help.

I have the following C++ structs struct InnerStruct { int A; int B; }; struct OuterStruct { int numberStructs; InnerStruct* innerStructs; }; And a C++ function OuterStruct getStructs(); How can I marshal this to C#? Where the C# definitions is struct OuterStruct { InnerStruct[] innerStructs; }; ...