marshalling

Can I force JAXB not to convert " into ", for example, when marshalling to XML?

I have an Object that is being marshalled to XML using JAXB. One element contains a String that includes quotes ("). The resulting XML has " where the " existed. Even though this is normally preferred, I need my output to match a legacy system. How do I force JAXB to NOT convert the HTML entities? -- Thank you for the replies....

How is a securestring marshalled to unmanaged code?

What prompted this question: I'm trying to change the account under which a windows service runs. I decided to use the win32 api rather than WMI and started looking at ChangeServiceConfig. I thought I could simply use the SecureString type in the unmanaged method signature and it would work fine. Hmmm, not quite. This made me wonder,...

C#/C++ interop - Need help defining my data structure

Hi, I am working on a C# app that is trying to use functionality provided via a C++ DLL. I am having a bit of a hard time getting the DLLImport definitions to work right at the moment. Here's the C++ side of the equation: struct Result { FLOAT first; FLOAT second; }; struct ResultData { UINT uint1; UIN...

Is it possible to force a string to be a specific size when defining a struct?

I am marshalling data between a C# and C++ application. In the C# application, I force the size of a string to be some size (say, 256 bytes). I would like to read in that exact same amount in C++ (I will be recreating the structs with reinterpret_cast) so that the data will remain formatted as it was in the C# application. Unfortunate...

Does C# have an equivalent to #pragma pack in C++?

C# provides StructLayoutAttribute.Pack, but its behaviour is "every member gets at least the specified alignment whether it wants it or not", whereas the behaviour of #pragma pack in C++ is "every member gets the alignment it wants, unless it wants more than the specified alignment, in which case it's not guaranteed to get more than that...

System.AccessViolationException

Hi, I am using a com DLL in the following manner: #Region "API Function" <DllImportAttribute("abc.dll", EntryPoint:="optcntl")> _ Public Shared Function optcntl(ByRef pBlocks As blocks) As Integer End Function #End Region This DLL using the other four dlls to complete its processing. If I change the current directory path ...

How to marshal .NET string to variant for COM call

I'm using a third-party COM library from C#. There are get/set methods that take a parameter of type VARIANT (type VT_BSTR). In the .NET wrapper, these parameters appear as type object, i.e. object getValue(); void setValue( object val ); The getValue method works ok, I perform a simple cast of the object to type string: string str ...

Why does marshalling a struct of callback delegates cause an AccessViolationException

Introduction I am trying to use P/Invoke to register a struct of callbacks with a native dll. When calling a function that makes the native dll invoke the callbacks an AccessViolationException occurs. I have constructed a "small" test case that demonstrates the behavior comprised of 2 files, native.cpp that compiles into native.dll and ...

Suitable XML Marshaller and Unmarshaller

Hi. We have an XML that needs to be converted to an object and vice versa. Something like Xstream does. Until now we were using Xstream to marshall and unmarshall the object/xml. However the problem is that an object that corresponds to XML in xstream, needs to have all the tags as attributes; else if XML contains any extra tags which ...

java.rmi.MarshalException

whenever I try to call my ejb from a client, I get this error : java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is: java.io.InvalidClassException: com.afrikbrain.util.message.MessageInfo; local class incompatible: stream classdesc serialVersionUI...

Marshalling .NET generic types

Here is a C# program that tries Marshal.SizeOf on a few different types: using System; using System.Runtime.InteropServices; [StructLayout(LayoutKind.Sequential)] class AClass { } [StructLayout(LayoutKind.Sequential)] struct AStruct { } [StructLayout(LayoutKind.Sequential)] class B { AClass value; } [StructLayout(LayoutKind.Sequent...

Is there a way to decrease overhead associated with out-proc COM calls?

Our program consumes an out-proc COM server and makes thousands of calls on its interfaces. This takes very very long time - like a minute for about 50k calls. The COM component vendor says that the calls are very fast by themselves and that the problem is in the overhead associated with out-proc calls. Is there anything that can be tun...

What is the preferred method of marshalling COM interfaces across threads?

What are the pros/cons of using the GIT as opposed to CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream for marshalling COM interfaces across threads? Are there strong reasons for preferring one method over the other, or is it more a matter of personal preference? ...

Marshalling structs from WM_COPYDATA messages

I am trying to get a C# WPF application to communicate with another application written in C using WM_COPYDATA. The C app is trying to send a struct as follows: typedef struct { int x; int y; char str[40]; double d; char c; } DATASTRUCT; In my C# app I have defined a struct as follows: [StructLayout(LayoutKind.Seq...

Marshalling strings, C++ to C#: 'conversion is not supported by the library'

Summary: When attempting to use marshalling to pass string data into a C++ DLL from C#, I'm getting 'msclr::interop::error_reporting_helper<_To_Type,_From_Type>::marshal_as': This conversion is not supported by the library or the header file needed for this conversion is not included. Please refer to the documentation on ...

Call unmanged Code from C# - returning a struct with arrays

[EDIT] I changed the source as suggested by Stephen Martin (highlighted in bold). And added the C++ source code as well. Hi, I'd like to call an unmanaged function in a self-written C++ dll. This library reads the machine's shared memory for status information of a third party software. Since there are a couple of values, I'd like to ...

Invoke C dll functions,structs and callbacks in C#

Below is the header file.can anyone please give a idea to call the callback function below. //Function Prototype int PASCAL EXPORT RegisterCallbackFunctions (TCallbacks CallbackFuncs); //Data Structure struct TCallbacks { LPONUSSDREQUEST m_pOnRequest; LPONUSSDRESPONSE m_pOnResponse; }; struct TData { DWORD m_dwCmd; BYTE ...

Marshalling and converting VB6 code to .NET

I am having trouble converting some code from VB6 to VB.NET (I don't have as much experience with .NET). When I run the 'Select function (from the WS2_32.dll library) in .NET, using the same parameters as the VB6 program, it returns a result of -1 (indicating an error). I think the error may be related to an upgrade comment I saw about m...

MSDN RPC marshal document wrong?

Hello everyone, I am using VSTS 2008 + Native C++ to develop RPC programs (both client and server). I am reading MSDN document for marshalling (The wire_marshal Attribute). I think this sentence is wrong: "For an [out]-only parameter, the server transmits to the client. The server needs the <type>_UserSize and <type>_UserMarsh...

Marshalling struct with embedded pointer from C# to unmanaged driver

Hi, I'm trying to interface C# (.NET Compact Framework 3.5) with a Windows CE 6 R2 stream driver using P/Invoked DeviceIoControl() calls . For one of the IOCTL codes, the driver requires a DeviceIoControl input buffer that is the following unmanaged struct that contains an embedded pointer: typedef struct { DWORD address; cons...