I am trying to use the COM interface from C #, which provides the following interface created by tlbimp:
[Guid("7DDCEDF4-3B78-460E-BB34-C7496FD3CD56")] [TypeLibType(TypeLibTypeFlags.FDual | TypeLibTypeFlags.FNonExtensible | TypeLibTypeFlags.FDispatchable)] public interface IFred { [DispId(1)] IBarney Pall { get; set; } } [Guid("E390230E-EE9C-4819-BC19-08DAB808AEA9")] [TypeLibType(TypeLibTypeFlags.FDual | TypeLibTypeFlags.FNonExtensible | TypeLibTypeFlags.FDispatchable)] public interface IBarney { [DispId(1)] double Wilma { get; set; } }
The generated assembly does not contain an implementation for the IBarney interface. I created a C # structure that implements the IBarney interface as follows:
[Guid("2C61BA37-7047-43DB-84B1-83B4268CF77B")] [ComVisible(true)] public struct Barney : IBarney { public double Wilma { get; set; } }
What โworksโ, now the question is, will the Barney instance be ordered by value or by reference? This is important due to network overhead. Perfectly does something like:
fredInstance.Pall = new Barney { Wilma = 0.37 };
will result in a single trip to the same network. How can I check this or how can I tell you that the COM interaction of my Barney structure should always be sorted by value?
Update:
Given the comment by Hans Passan. What would be the โrightโ way to develop it? What will be the IDL to allow a simple structure to be used as the value for the "property" of the COM interface? Looking at the IDL from which the interfaces I'm currently using are being created, adding a coclass with an IBarney interface by default will be enough, right?
c # marshalling com com-interop
Bas bossink
source share