![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi Everyone, I have a .NET 2.0 set of classes that i've recently attempted to call from an MFC application using regasm to generate and register a type library. I didn't author my classes with the intention that they would be called from an unmanaged application and i've run into a few problems. Let's say for example that i have a Class A. I could see this class in the MFC app, but i couldn't see any of it's public methods or properties. It wasn't until I made Class A implement Interface A that I could see the methods using the interface and the following code IClassA clsA(__uuidof(ClassA)); But what if I want Class A to inherit from two interfaces. If I can indeed only access my methods using the interface, do I have to create two variables, one for each interface? I'm seriously hoping i've got something wrong along the way ![]() thanks, Andrew |
#3
| |||
| |||
|
|
Hi Andrew, If an object exposes multiple interfaces, you need a separate interface variable to access each one. This allows clients to program to an interface rather than implementation and affords decoupling. This is good practice in general, so that when someday you need to replace ClassA with SomeOtherAClass your clients only need to update the CoClass. "Andrew Brook" wrote: Hi Everyone, I have a .NET 2.0 set of classes that i've recently attempted to call from an MFC application using regasm to generate and register a type library. I didn't author my classes with the intention that they would be called from an unmanaged application and i've run into a few problems. Let's say for example that i have a Class A. I could see this class in the MFC app, but i couldn't see any of it's public methods or properties. It wasn't until I made Class A implement Interface A that I could see the methods using the interface and the following code IClassA clsA(__uuidof(ClassA)); But what if I want Class A to inherit from two interfaces. If I can indeed only access my methods using the interface, do I have to create two variables, one for each interface? I'm seriously hoping i've got something wrong along the way ![]() thanks, Andrew |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |