marshalling

Marshalling Date type

I'm trying to marshal a VB6 structure but I don't know how to marshal the Date type ex: DateSaved As Date and the following array of strings: FASTNESSNAME(1 To 6) As String * 16 Thanks in advance for the help. ...

How to use JAXB to marshall/unmarshall a collection of MyBean

I have a MyBean annotated @XmlRootElement public class MyBean ... Marshalling/Unmarshalling MyBean w/o problems, e.g. JAXBContext jaxbCtx = JAXBContext.newInstance(MyBean.class); Marshaller m = jaxbCtx.createMarshaller(); m.marshal(myBean, writer); How can I use JAXB to marshall/unmarshall a Collection or List? My attempt results ...

What are the C# equivalent of these C++ structs

typedef union _Value { signed char c; unsigned char b; signed short s; unsigned short w; signed long l; unsigned long u; float f; double *d; char *p; } Value; typedef struct _Field { WORD nFieldId; BYTE bValueType; Value Value; } Field; typedef s...

Can marshalling or packing be implemented by unions?

In beej's guide to networking there is a section of marshalling or packing data for Serialization where he describes various functions for packing and unpacking data (int,float,double ..etc). It is easier to use union(similar can be defined for float and double) as defined below and transmit integer.pack as packed version of integer.i, ...

Returning pointers from unmanaged to managed code

I've an unmanaged dll that exports the folowing function: SomeData* test(); Let's assume SomeData as: typedef struct _Data Data; struct _Data{ int a; int b; } Now i want to call this function from C# code. I start to define the C# Struture needed to custom marshaling like this: [StructLayout(LayoutKind.Sequen...

Technical choices in unmarshalling hash-consed data

There seems to be quite a bit of folklore knowledge floating about in restricted circles about the pitfalls of hash-consing combined with marshalling-unmarshalling of data. I am looking for citable references to these tidbits. For instance, someone once pointed me to library aterm and mentioned that the authors had clearly thought about...

Exchange stuctures (envolving pointers to other structures) between C and C#

I want to use PInvoke to bring to managed side something this: (C code) typedef struct{ //some fields... } A; type struct{ A* a; } B; int getB(B* destination){ //destionation will be an output parameter to C# //puts an B in 'destination' return 0; } Now, i need a way to tell managed...

Passing c# string to unmanaged c++ DLL

Hi All, I have a simple application that loads an unmanaged dll and passes a few string values to it from C#. But in the C++ dll application, I receive an exception :: Tried to access a read/write protected memory. My DLL Import looks like this: [DllImport("X.dll", CallingConvention = CallingConvention.Cdecl) ] public static extern int...

JAXB lists namespaces in root element (-> each element)

By default, jaxb 2 lists all (all possible required) namespaces in root element during marshalling: Is there a way to describe namespace in each element instead of root element ?: It also solves the problem of "unnecessary namespaces", which is also important in my case. Any suggestions appreciated. ...

jaxb namespaces in each element instead of root element during marshalling

By default, jaxb 2 lists all (all possible required) namespaces in root element during marshalling: <rootElement xmlns="default_ns" xmlns:ns1="ns1" xmlns:ns2="ns2"> <ns1:element/> </rootElement> Is there a way to describe namespace in each element instead of root element ?: <rootElement xmlns="default_ns"> <...

Castor Mapping Arrays

Hi, I've got a class that has constructor: public ContEmpirical(double xs[], double fs[]) { Check.check(xs.length == fs.length + 1 && fs.length > 0, "Empirical distribution array mismatch"); this.xs = new double[xs.length]; this.xs = xs; this.cs = new double[xs.length]; double fTotal = 0.0; for (int...

Calling C# From Unmanaged C++ Passing Or Returning "Complex" Types

Hello, I'm after help on how to use complex objects either as return values or passed as parameters to C# class methods exposed to unmanaged C++ as COM components Here's why: I'm working on a project where we have half a dozen unmanaged C++ applications that each directly access the same Microsoft SQL Server database. We want to be ab...

Has anyone used the Win32 API function CredWrite in .NET?

I'm trying to use CredWrite, but get an ERROR_INVALID_PARAMETER 87 (0x57) error. The intent is to have a secure place to save the user's password for my .net WPF application. And my code: public class CredMan { private const string TARGET_PREFIX = "myappname:"; public static void SavePassword(string username, string password)...

JAXB marshalling superclass

I am writing a Resteasy server application and am having trouble getting my superclasses to marshal. I have code something like this: @XmlAccessorType(XmlAccessType.NONE) @XmlRootElement(name = "person") class Person { protected String name; @XmlElement(name = "name") public String getName() { return name; } public void setNam...

Spring with Castor - Null Pointer Exception when initialising Application Context

Hi, I'm trying to register my castor mapping files with spring and I appear to be getting a null pointer exception. In my application context I have: <bean id="xmlContext" class="org.castor.spring.xml.XMLContextFactoryBean"> <property name="mappingLocations"> <list> <value>DistributionSamplerMappings.xml</value>...

Interface Marshalling in Delphi

I want to send Interface Ref of IVApplication from Visio Add-in to my other one COM server. But I have Ole exception. Now i do that: Code in Visio Add-in: var IStrm: IStream; hres: HResult; rhglobal: HGLOBAL; VisioAppl: IVApplication; begin hres := CreateStreamOnHGlobal(0, TRUE, IStrm); if Succeeded(hres) then ...

Why can't pass Marshaled interface as integer(or pointer)

I passed ref of interface from Visio Add-ins to MyCOMServer (http://stackoverflow.com/questions/2455183/interface-marshalling-in-delphi).I have to pass interface as pointer in internals method of MyCOMServer. I try to pass interface to internal method as pointer of interface, but after back cast when i try call method of interface I ge...

How can I find out if an instance is a MarshalByRef proxy?

I know there's a way, I know I've done it (a long time) before, but I can't remember or find out how to do it!!! var otherDomain = AppDomain.Create("Lol my memory sucks"); var myRemotableType = typeof(MyTypeThatExtendsMBRO); var proxy = otherDomain .CreateInstanceAndUnwrap( type.Assembly.FullName, type.FullName); // how...

SWIG: C++ to C#, pointer to pointer marshalling.

I have some legacy code I want to port to C#. I cannot modify the C++ code, I just have to make do with what I'm given. So, the situation. I'm using SwIG, and I came across this function: void MarshalMe(int iNum, FooClass** ioFooClassArray); If I ran SWIG over this, it wouldn't know what to do with the array, so it will create a SWIG...

Java marshaller performance

Hi, I've used JAXB Marshaller as well as my own marshaller for marshalling pure java bean objects into XML. It has been observed that both of them require almost same time to marshal. The performance is not acceptable and needs to be improved. What are possible ways where we can improve performance of marshaller? Like threading? ...