marshalling

Castor Collection Field to empty

My castor masrshaller have an XML output as below root> field1 /field1> field2 /field2> .......... fieldn> collection> field> field> .......... field> /collection> /root> my mapping for the collection part is field name="collectionObj" type="string" collection="arraylist"> bind-xml name="...

Marshaling from C# to C++

Hi everyone. I gotta pass an InParameter from my C# application to an exported function from a VC++ DLL. The function accepts 2 parameters : int func_name (FILE* fp, BYTE& by); fp is In and by is Out parameter. I was thinking of marshaling using IntPtr for the FILE* and using byte for BYTE. Is it correct? If I write the following in C...

Marshalling a struct containing c-strings

I have a C++ struct struct UnmanagedStruct { char* s; }; and a C# struct struct ManagedStruct { [MarshalAs(UnmanagedType.LPStr)] string s; } the C++ library exposes extern "C" UnmanagedStruct __declspec(dllexport) foo( char* input ); And it is imported like [DllImport("SomeDLL.dll", CharSet = CharSet.Ansi)] static ex...

Does a "pure" IDispatch interface require a proxy/stub DLL?

..for an out-of-process-server, or can I call a dispatch interface without registering a proxy/stub? The interface in question is very high level, so performance is a non-issue, and I could make the whole thing registration-free, which is a big plus ...

PInvoke error when marshalling struct with a string in it

I have a C++ struct struct UnmanagedStruct { char* s; // Other members }; and a C# struct struct ManagedStruct { [MarshalAs(UnmanagedType.LPStr)] string s; // Other members } the C++ library exposes extern "C" UnmanagedStruct __declspec(dllexport) foo( char* input ); And it is imported like [DllImport("SomeDLL.dl...

JAXB: Can I make XmlAttribute's parameter "required=true" to default?

Hello! I have @XmlAttribute(required=true) in hundreds places in a projects. Can I make this default?... ...So that I then only need to specify @XmlAttribute(required=false) when needed. ...

Marshalling unmanaged code in silverlight

Hello all, I've got this small web application I've built. It's got an activex control returning unmanaged code through javascript into a silverlight application. In silverlight I perform a marshaling operation on the returned value. When I only perform the simple operation of GetSize() I get struck with a stupefing error. This brings m...

Marshalling an unknown Array size

You have a structure that takes a byte array byte[] however, the size of that array depends on the image you are submitting (widthxheight) So... how do you do [MarshalAs(UnmanagedType.ByValArray, SizeConst = ???)] public Byte[] ImageData; Is the sizeconst a MUST HAVE when working with byte arrays being passed from C# to C dlls? ...

C# Get progID from COM object

Hi, i would like to know if there is a way to get the progId of a com object in c#. eg - i have a webBrowser object that exposes a document object which is COM. is there a way to figure out what the progID of that document object is? I know you can get the object from progID, just not sure how to do the other way around. Thanks. ...

Why does MarshalByRefObject.InitializeLifetimeService return an object and not an ILease?

I am reading through the msdn docs for .NET Remoting and noticed that the MarshalByRefObject.InitializeLifetimeService method returns an object instead of an ILease. The documentation says that the method returns an object of type ILease and all code examples I have found casts the returned value to an ILease. But the methods signature s...

Is there something like JAX-B for C#?

We are searching for an Library which supports the marshalling and unmarshalling like JAX-B in Java, is there any state-of-the-art library to use? ...

How do I GetCustomAttributes?

I have tried the following code using the 2.0 framework and I get an attribute back, but when I try this on the compact framework, it always returns an empty array. The MSDN documenation says its supported, am I doing something wrong? Test x = new Test(); FieldInfo field_info = x.GetType().GetField("ArrayShorts"); object[] custom...

Marshalling out array of user-defined type between VB6 and .net

Hello, I'm creating a COM callable .net assembly and now trying to use it from legacy COM clients (VB6 client in my case). Assembly should expose API style interface, so typical function declaration would look like this: int myRoutine (object inParam, out object result); The problem is when I trying to use function declared as: ...

Serialize/marshal/reverse engineer unknown structure

Is there a way to deserialize or marshal or somehow parse a byte array back into a structure when you don't know what that structure was in the first place? The structure probably came from C++. Some background: I have a flight simulator for R/C planes and I'm trying to figure out if I can automate it. There is no API. I know how to aut...

What happens if I marshal a null pointer using the [MarshalAs(UnmanagedType.LPStr)]

If I try a marshal a string that is really a NULL pointer, what will happen? ...

Convert structure to byte array in .NET

I wish to write a structure made up of fixed length strings to a file using My.Computer.FileSystem.WriteAllBytes or the like. I am using a VB6 project with fixed length strings that I have converted in to VB.Net. Structure Record <VBFixedString(22),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.Unmanag...

C++ .NET convert System::String to std::string

How do you convert System::String to std::string in C++ .NET? ...

Marshalling vs ActiveRecord Serialization in Ruby On Rails

What is the difference between Marshalling and ActiveRecord Serialization? Is there any particular occasion when it is preferable to use one over the other to save an object to the database? ...

Marshalling CodeElements to an IntPtr in C#

I am writing a Visual Studio add in and need to marshall a managed CodeElements object to it's unmananged form. I just need the pointer in memory, as I can cast it and treat it like a CodeElement on the unmanaged side. [DllImport("CodeMethodsToString.dll")] private static extern BSTR* CodeMethodsToString(void* functionObject); p...

.NET Marshaler: Good documentation?

I'm currently working on some C# code that calls into a custom, native dll. When marshaling data back to C#, I have need to explicitly align the fields of the classes/structs used for marshaling. I've had a number of issues with this stemming from an incomplete understanding of the marshaler and its rules. For example, I recently foun...