C++/CLI Interfaces

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?TkVXMi5ORVQ=?=

    #1

    C++/CLI Interfaces

    Two questions:

    1) I have an assembly that defines the interface for a component. The
    assembly only contains the interface (as per component development guidance),
    a different assembly contains the C++ classes that implement the interface.
    When I write a VB app that references both strong named assemblies, the
    VS2005 object browser and intellisense tells me the namespace (shared by both
    interface and implementation class) identifier is ambiguous because the
    interface is showing up in both assemblies. What am I doing wrong?

    2) I have a few static events on an C++ implementation class found in a
    strong named assembly. All works fine when a simple VB app references the
    assembly, the VB app can register for and receive the events but has to
    reference the C++ class in the assembly. If I try to add the events to the
    interface the C++ class implements, I get compile errors that indicate you
    cannot have static events on an interface. If I get rid of the static
    modifier, all heck breaks loose. Any suggestions (note the events pass
    arguments)?

    Thanks
  • Tamas Demjen

    #2
    Re: C++/CLI Interfaces

    NEW2.NET wrote:
    1) I have an assembly that defines the interface for a component. The
    assembly only contains the interface (as per component development guidance),
    a different assembly contains the C++ classes that implement the interface.
    When I write a VB app that references both strong named assemblies, the
    VS2005 object browser and intellisense tells me the namespace (shared by both
    interface and implementation class) identifier is ambiguous because the
    interface is showing up in both assemblies. What am I doing wrong?
    Are you sure the C++ implementation is referencing the assembly instead
    of including it? You have to reference it with #using, not copy-pasting
    it with #include. If you use #include, it will certainly be a completely
    separate class with the same name, thus causing duplicate identifiers.

    I can't comment on #2, never done that before.

    Tom

    Comment

    • Ben Voigt

      #3
      Re: C++/CLI Interfaces

      2) I have a few static events on an C++ implementation class found in a
      strong named assembly. All works fine when a simple VB app references the
      assembly, the VB app can register for and receive the events but has to
      reference the C++ class in the assembly. If I try to add the events to
      the
      interface the C++ class implements, I get compile errors that indicate you
      cannot have static events on an interface. If I get rid of the static
      modifier, all heck breaks loose. Any suggestions (note the events pass
      arguments)?
      While an interface can have static members in .Net, they aren't in any way
      connected to classes implementing that interface. Interfaces define a
      contract on objects (instances) that implement the interface, not on
      classes.
      >
      Thanks

      Comment

      Working...