Before you can begin to build a marshaler, the managed an unmanaged interfaces being marshaled must be defined. These interfaces commonly perform the same function but, for one reason or another, are exposed differently in the managed and unmanaged world.
The managed interface is defined in metadata produced by a managed compiler. It looks like any other managed interface.
In New.h #using <mscorlib.dll> interface INew { void NewMethod(); }
The unmanaged type is defined in IDL and compiled with the MIDL compiler. The interface is defined within a library statement and is assigned an interface ID with the uuid attribute.
In Old.idl [uuid(9B2BAADA-0705-11D3-A0CD-00C04FA35826)] Library OldLib { [uuid(9B2BAADD-0705-11D3-A0CD-00C04FA35826)] interface IOld : IUnknown HRESULT OldMethod(); }
The unmanaged interface is compiled with the MIDL compiler. The MIDL compiler produces several output files. If the interface is defined in old.Idl, the output file old_i.c defines a const variable with the IID of the interface:
In Old_i.c const IID IID_IOld = {0x9B2BAADD,0x0705,0x11D3,{0xA0,0xCD,0x00,0xC0,0x4F,0xA3,0x58,0x26}};
The file Old.h is also produced by MIDL. It contains a C++ style definition of the interface that can be #included into your C++ source code.