Click here to Skip to main content
15,916,941 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hey everyone,

When i create an instance of an object in my local COM-Server the class is requested to provide various interfaces which are marshaling related. As ive seen in the web the default marshaler can be used but for that either a proxy DLL has to be there or a typelib should be used. I created an ODL file describing my interface and class:
C++
import "oaidl.idl";
import "ocidl.idl";

[
	object,
	uuid(3DBCAC5E-1A1B-4E56-B9AD-DCF19597B869),
	pointer_default(unique)
]
interface ITestClass : IUnknown {
	[id(1)] HRESULT Foo(int);
};

[
	uuid(737BB030-CE7A-4361-9C7E-1A1D697B9493),
	version(1.0),
]
library LocalServerLib
{
	importlib("stdole2.tlb");
	[
		uuid(3DBCAC5E-1A1B-4E56-B9AD-DCF19597B868)
	]
	coclass TestClass
	{
		[default] interface ITestClass;
	};
};


With the according definition:
C++
class __declspec(uuid("{3DBCAC5E-1A1B-4E56-B9AD-DCF19597B869}"))
ITestClass : public IUnknown
{
public:
	virtual HRESULT Foo(int value) = 0;
};

// just used for __uuidof, in the server its fully declared
class __declspec(uuid("{3DBCAC5E-1A1B-4E56-B9AD-DCF19597B868}")) 
TestClass
{
};


The typelib is registered using RegisterTypeLibForUser and my class has an entry TypeLib with the GUID of the registered type lib.

But well, still COM requests all the marshaling from my class. Am i missing something?

Greetings and thanks
Regner
Posted

add the oleautomation tag to your interface definition, and the tlb marshalling will start
 
Share this answer
 
"Server" sounds like "DCOM" (Distributed COM). It is another technique "out of the M$-Hell".

I advise you to look for a working sample and modify it. Dont ferget to modify the UUIDs ;-)

Cant you use an other technology as XML via some Webservices. That works easy via C#.
 
Share this answer
 
Comments
Regner44 9-Jun-11 10:14am    
Hey, sadly no, i have to use the old DCOM way. But actually i solved the problem by using a proxy stub that handles marshalling. Visual Studio generates everything necessary from the IDL file describing the interfaces i use. I just need to register it like any other in process component.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900