![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Expose a .NET interface to COM as an interface Hello, does anyone know if there is a way to expose a .NET interface to COM as such? Suppose I have code like this: [ComVisible(true)] [Guid("....")] interface IMyInterface { void Method1(); void Method2(); } but that does not expose this interface to COM clients, which is logical, because there is no named identifier specified (.NET does not allow me to specify [ProgID("...")] attribute to provide a name for the interface as it does for classes). Now, I can easily create a .NET class, make it ComVisible and specify IMyInterface as the default interface. In this case, I can access this interface by COM clients. But I want the client to see IMyInterface as such, and possibly let an external COM class (say written in VB6) implement it. Can this be done? Thanks in advance for your help, pierre_k. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Expose a .NET interface to COM as an interface Well, that should work - have you tried making the interface public? (it is implicitly "internal" in the code posted) See here: http://msdn.microsoft.com/en-us/library/46f8ac6z.aspx Marc |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Expose a .NET interface to COM as an interface On Jun 19, 12:13 pm, Marc Gravell <marc.grav...@xxxxxx> wrote: Quote: > Well, that should work - have you tried making the interface public? (it > is implicitly "internal" in the code posted) > > See here:http://msdn.microsoft.com/en-us/library/46f8ac6z.aspx > > Marc part from the code. Actually, I can see my interface in the exported typelibrary (.tlb file opened with OleView), but it's not visible from VB6 (using the Object Browser). I have also tried marking the interface with <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> and <InterfaceType(ComInterfaceType.InterfaceIsIDispatch)>, but that does not make any difference. Any suggestions on what I'm doing wrong? Thanks, pierre_k |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Expose a .NET interface to COM as an interface Well, after few hours of fiddling around I found out what the issue here is. Apparently, when you define a NET interface along with a ComVisible class with your interface set as the default one (using ComDefaultInterface attribute), VB6 hides this default interface entirely from you. Then, when you want to work with that interface in VB6, you use the name of that implementing class instead. In any case thank for help, it definitely made me look in the right direction. pierre_k |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Interface questions | Vista General | |||
| Aero Interface | Vista performance & maintenance | |||
| Aero Interface | Vista General | |||
| Alt+Tab interface | Vista file management | |||