I have a client written in C++ as a ATL COM application and a server in C#
that lives inside a CLR hosted by this client. The C# server defines a
COM-visible structure and an interface with a method that returns an array of
such structures, such as below. When the C++ host calls the method, I get
"0x80028019 Old format or invalid type library". This despite the fact that
the type library and headers included by the host are just freshly generated
by Visual Studio. What could be wrong with this scenario?
For details, see below.
This is what my .NET server exposes.
[ComVisible(true)]
public struct ObjectID
{
private Int64 identifier;
private Int32 type;
private Int32 attributes;
private string name;
}
[ComVisible(true)]
public interface IService
{
bool GetObjects([In] Int64 context, [Out] out ObjectID[] objects);
}
The C++ client hosting the .NET server consumes the tlb as below.
#import "C:\QuickSilver\QuickSilver_Service.tlb" raw_interfaces_only
high_property_prefixes("_get", "_put", "_putref") rename_namespace("QSS")
krzys - 08 Aug 2006 04:16 GMT
Never mind that I made fields private, doesn't work either way. Below is a
piece of the header file generated from teh type library. To me this looks
perfectly valid and I have no clue what's going on.
struct __declspec(uuid("2ac5e284-1855-300e-bb24-28a51e6ffa37"))
ObjectID
{
__int64 identifier;
long type;
long attributes;
LPSTR name;
};
struct __declspec(uuid("ef585848-5d81-30fb-a8ac-0d797b977f26"))
IService : IDispatch
{
virtual HRESULT __stdcall GetObjects (
__int64 context, SAFEARRAY * * objects, VARIANT_BOOL * pRetVal ) = 0;
};