c# - DispID must be unique across interfaces? -


i use com old vb6 application.

i changed code use dispid in interfaces seems work better using [classinterface(classinterfacetype.autodual)].

but allowed begin in each interface counting dispid(1), when class uses 2 interfaces?

does work way stable? or missunderstood something?

[comvisible(true)] [guid("9e1125a6-...")] public interface imyinterface1 {     [dispid(1)]     string name1 { get; } }  [comvisible(true)] [guid("123425a6-...")] public interface imyinterface2 {     [dispid(1)]     string name2 { get; } }  [comvisible(true)] [classinterface(classinterfacetype.none)] class myclass : imyinterface1, imyinterface2 {     public string name1 { { return "name1"; } }     public string name2 { { return "name2"; } } } 

is allowed begin in each interface counting dispid(1), when class uses 2 interfaces?

dispids have unique within interface only. go 2 interfaces each 1 having own (different) dispid 1 properties, if both interfaces implemented same com object.

since vb6 mentioned, however, need keep in mind vb6 won't 2+ dispatch interfaces implemented on same com object, , might "seeing" first/main one. is, problem not dispid collision (which not problem @ all), fact vb6 unable work correctly objects exposing 2+ dual interfaces. reason why happening in described on msdn in multiple dual interfaces:

because 1 idispatch interface exposed, clients can access objects through idispatch interface not able access methods or properties in other interface.

and sadly, case of vb6. unlike more advanced environments, querying interfaces in way "methods or properties in other interface" inaccessible. assigning different dispids not going there though.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -