When I ask Visual Studio to generate runtime callable wrappers for my COM components, it is selecting a strange type to wrap a certain interface property.
This is a summarized type library for component A:
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: prodist.sts.dll
[
uuid(DD00B52D-D8F9-4D5C-ADBD-4E05A68A48CB),
version(5.4),
custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 134218331),
custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 1423075247),
custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, "Created by MIDL version 8.00.0603 at Wed Feb 04 16:40:46 2015
"),
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "prodist.sts")
]
library prodist_sts
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// TLib : : {F11596CA-03EE-4756-B502-0327800ED8B4}
importlib("prodist.logging.dll");
// Forward declare all types defined in this typelib
interface ISts;
interface IStsSession;
interface IStream;
interface ISequentialStream;
[
uuid(EE263AAA-67D4-48DD-9DF5-69ED8CF0D0C9)
]
coclass Sts {
[default] interface ISts;
};
[
odl,
uuid(8D841E5C-F25B-4C12-B03A-70A899B3A32E),
dual,
nonextensible,
oleautomation
]
interface ISts : IDispatch {
[id(0x000003e9), propget]
HRESULT Logging([out, retval] IProdistLoggingHierarchy** value);
[id(0x000003e9), propput]
HRESULT Logging(IProdistLoggingHierarchy* value);
[id(0x000003e8)]
HRESULT CreateSession([out, retval] IStsSession** result);
};
// ...
}
This is the type library for component B:
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: prodist.sts.rsfn.dll
[
uuid(C8FBF2B0-9218-4B0D-9509-C394D65F0566),
version(5.4),
custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 134218331),
custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 1423076189),
custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, "Created by MIDL version 8.00.0603 at Wed Feb 04 16:56:28 2015
"),
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "prodist.sts.rsfn")
]
library prodist_sts_rsfn
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// TLib : : {DD00B52D-D8F9-4D5C-ADBD-4E05A68A48CB}
importlib("prodist.sts.dll");
// TLib : : {F11596CA-03EE-4756-B502-0327800ED8B4}
importlib("prodist.logging.dll");
// Forward declare all types defined in this typelib
interface IApiMensageria2;
interface IApiMensageria;
interface IApiMensageriaContext;
interface IStsRsfn;
interface IStsRsfnContext;
interface IStsRsfnSession;
[
uuid(914E8C54-E0F0-4322-8803-8E9EEEE03A01)
]
coclass StsRsfn {
[default] interface IStsRsfn;
};
[
odl,
uuid(13385FC6-2618-4830-A3A9-703398AA5A0B),
dual,
nonextensible,
oleautomation
]
interface IStsRsfn : IDispatch {
[id(0x000003e9), propget]
HRESULT Logging([out, retval] IProdistLoggingHierarchy** value);
[id(0x000003e9), propput]
HRESULT Logging(IProdistLoggingHierarchy* value);
[id(0x000003e8), propget]
HRESULT Sts([out, retval] ISts** value);
[id(0x000003e8), propput]
HRESULT Sts(ISts* value);
[id(0x000003f1)]
HRESULT CreateContext([out, retval] IStsRsfnContext** result);
[id(0x000003f2)]
HRESULT CreateSession([out, retval] IStsRsfnSession** result);
};
// ...
}
This is the runtime callable wrapper generated by Visual Studio for component A:
[ClassInterface(0)]
[Guid("EE263AAA-67D4-48DD-9DF5-69ED8CF0D0C9")]
[TypeLibType(2)]
public class StsClass : ISts, Sts
{
public StsClass();
[DispId(1001)]
public virtual IProdistLoggingHierarchy Logging { get; set; }
[DispId(1000)]
public virtual IStsSession CreateSession();
}
[CoClass(typeof(StsClass))]
[Guid("8D841E5C-F25B-4C12-B03A-70A899B3A32E")]
public interface Sts : ISts
{
}
[Guid("8D841E5C-F25B-4C12-B03A-70A899B3A32E")]
[TypeLibType(4288)]
public interface ISts
{
[DispId(1001)]
IProdistLoggingHierarchy Logging { get; set; }
[DispId(1000)]
IStsSession CreateSession();
}
This is the runtime callable wrapper generated by Visual Studio for component B:
[ClassInterface(0)]
[Guid("914E8C54-E0F0-4322-8803-8E9EEEE03A01")]
[TypeLibType(2)]
public class StsRsfnClass : IStsRsfn, StsRsfn
{
public StsRsfnClass();
[DispId(1001)]
public virtual IProdistLoggingHierarchy Logging { get; set; }
[DispId(1000)]
public virtual Sts Sts { get; set; }
[DispId(1009)]
public virtual IStsRsfnContext CreateContext();
[DispId(1010)]
public virtual IStsRsfnSession CreateSession();
}
[CoClass(typeof(StsRsfnClass))]
[Guid("13385FC6-2618-4830-A3A9-703398AA5A0B")]
public interface StsRsfn : IStsRsfn
{
}
[Guid("13385FC6-2618-4830-A3A9-703398AA5A0B")]
[TypeLibType(4288)]
public interface IStsRsfn
{
[DispId(1001)]
IProdistLoggingHierarchy Logging { get; set; }
[DispId(1000)]
Sts Sts { get; set; }
[DispId(1009)]
IStsRsfnContext CreateContext();
[DispId(1010)]
IStsRsfnSession CreateSession();
}
Why is Visual Studio selecting the Sts interface instead of the ISts interface to wrap the IStsRsfn.Sts property?
Because the interface ISts
is the default interface for the Sts
coclass and no other coclass implements it.
In this case, I guess the importer chooses the interface it once saw as the default for some coclass and implemented by no other.