marshalling

COM marshalling problem with modal dialog

I would like to pass a COM object created in the main thread of my C++/MFC8 program to a different thread, and leave all synchronization to COM. Using CoMarshalInterThreadInterfaceInStream works -- until the user opens a modal dialog. While the dialog is open, apparently all marshalling messages are rejected, which I sort of understand b...

How to make .NET not to use registered TLB to marshal calls to COM methods?

Current configuration is: The main application is unmanaged. It contains DLL, containing TLB, which describes functions, exposed to COM model. To support ASMX web services, it loads .NET framework, and starts ASP.NET domain that serves web service calls. To serve web service calls, it needs data from the main application. So, we'r...

GlobalInterfacePointer passing using AfxBeginthread

Hi, I am using a worker thread inside a CDialog class. theApp.m_pWorkerThread = AfxBeginThread(Threadproc,this); Now I need to pass a global Inerface poiner to the worker thread so as to access a COM object from outside Can someone tell me the syntax to pass the GIT cookie and access it inside the thread. Thanks ...

What is Serialization/Deserialization and marshalling/unmarshalling with example?

recently i read about interface iclonable,in that i studied about serialization and marshalling i like to know about that with examples. ...

JiBX: Creating a marshaller for non-global elements?

So we have a given XSD such as this: <xsd:element name="SomeRequest"> <xsd:complexType> <xsd:sequence> <xsd:element name="RegistrationDetail" type="RegistrationDetailType" minOccurs="0" /> </xsd:sequence> </xsd:complexType> </xsd:element> <...

AccessViolationException when calling Marshal.PtrToStructure

Hi, I'm getting an AccessViolationExcpetion by calling Marshal.PtrToStructure(intPtr, typeof(Servent)). Any ideas what I have done wrong? I tried this on x64. IntPtr intPtr = NativeMethods.GetServByName(name, "tcp"); if (intPtr != IntPtr.Zero) { Servent servent = (Servent)Marshal.PtrToStructure(intPtr, typeof(Ser...

Returning Struct from VC++ to C#.

Hi, I have written a structure in VC++. I have made a dll of the VC++ code and calling this dll in C# using PInvoke. The VC++ dll looks like this #include <windows.h> #include <stdio.h> #include <conio.h> #include <tchar.h> #include <iostream> #if defined(_MSC_VER) #include <windows.h> #define DLL extern "C" __declspec(dllexport) #els...

marshal_as, strings and fields vs. properties

Hello, #include "stdafx.h" #include <string> #include <msclr/marshal_cppstd.h> ref class Test { System::String^ text; void Method() { std::string f = msclr::interop::marshal_as<std::string>(text); // line 8 } }; This code when compiled with VS2008 gives: .\test.cpp(8) : error C2665: 'msclr::interop::marshal_as' :...

grails / groovy / cxf / jaxb - hibernate persisted entity marshalled as empty

Expecting grails domain object to be written to XML response: Image.groovy: @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) class Image{ @XmlElement String url @XmlElement String contentType } WebServiceRequestHandler.groovy: @GET @Path("/myrestfullmethod/parameter1/{parameter1name} @Produces("text/xml") Images...

CLS compliant types in P/Invoke helper assembly

Having a separate helper assembly containing only P/Invoke declarations for legacy 3rd party components, I wonder which of these two ways is The Better One™ if the assembly must be marked CLS compliant: Use Int32 in a public P/Invoke declaration where the unmanaged declaration has unsigned int. Use UInt32 in an internal P/Invoke declar...

converting a byte array from a native method to a managed structure

I have a c# .net 2.0 CF application that interfaces with a native DLL implementing a function like this: struct NATIVE_METHOD_REPLY { int other_irrelevant_data; int data_size; void* data; } // reply_buffer will contain an array of NATIVE_METHOD_REPLY structures // and their data. // // returns an error code int Foo(NATIVE_M...

Best practice of sending array from native code to managed code(C++/CLI)?

I'm writing a win32 dll for read/write USB HID device. The data for exchange is a 64 byte unsigned char array. The client program is written in C++/CLI. In order to achieve max speed and minimum overhead, I need an efficient way to sending the array to managed client. There are two options I can think of right now: Native: use PostMe...

Marshal ruby hash with default proc - remove the default proc?

I've got a Hash with a default proc that I'd like to to Marshal to a file, but the default proc prevents me from doing that. Rather than writing my own _dump and _load methods, is it possible instead to remove the default_proc instead? At the point where I'm Marshalling I'm never going to need the default_proc again. ...

How do I marshall (in ideally in SWIG) a C# string[] to a C++ string*?

I am new in C# programming and trying to call wrap functions that is in C++. In C++ I have a function of the following prototype string* swap(string* ptr1, string*ptr2){ //swap the array of string return ptr2; } How do I wrap this function into C# (ideally using SWIG, but not necessary)? ...

Field-wise comparison of unmanaged struct

For test purpose, I want to compare two structs (of unknown type T) marshaled from unmanaged code. Because they may contain some packing in unmanaged representation, it is inappropriate to convert whole struct to byte array and then compare byte by byte: int size = Marshal.SizeOf(typeof(T)); IntPtr buf1 = Marshal.AllocHG...

Demarshalling XStream errors

Hi everyone, I have successfully created an XML file using XStream and a custom converter. The custom converter marshalls an object so it is nicely readable by humans as follows: <Header clip="16:01:02:22 -&gt; 16:01:52:00" match clock="961"> <match filename="MatchName" name="Jets vs Giants" date="2009-11-29 16:00:00.0"/> </Header> ...

Passing an C# array of structs with array of double member to C DLL by reference

We have the following code marshalling between c# and c dll. However, when print the value within the C dll function, the values associated with the double array properties are all 0.0000000. I have put some in line comments for the code having problems. Did we miss any thing to configure the marshalling behaviour? using System; using...

Using C# managed structures/classes with Windows API

I'm sick of using Marshal.Copy, Marshal.Read* and Marshal.Write* so I was wondering if there's a way to force casting of an unmanaged memory pointer (of type IntPtr). Something like this: IntPtr pointer = Marshal.AllocateHGlobal(sizeof(Foo)); Foo bar = (Foo)pointer; bar.fooBar = someValue; // call some API Marshal.FreeHGlobal(pointer);...

Marshal a field/property to an xml-element with an additional xml-attribute name=propertyName

Hi everyone, I have a java object like: public class Person { private String firstName = "Harry"; private String lastName = "Hacker"; private int age = 30; } which I would like to marshal into the following xml: <attribute xsi:type="someType" name="Person"> <attribute xsi:type="CustomStringType" name="firstName"> <v...

Custom Parcelable object passed to core

I want to send a broadcast message with intent within extra data of my custom type which implements Parcelable. In more details: I want to create a shortcut on the HS However system does not accept object of my custom Command type, error message: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.solvek.us...