RE: VC++ Class Library and Implenting COM Interfaces??

From: Peter Huang (v-phuang_at_online.microsoft.com)
Date: 12/01/04


Date: Wed, 01 Dec 2004 06:01:00 GMT

Hi

Based on my understanding, you wants to expose the .NET class to the COM
interface, if I have any misunderstanding, please feel free to let me know.
In MC++, we can do the job below to expose the IMyInterface to the COM
client, after built we need to use the regasm to generate the tlb file for
com client to use.

using namespace System;
using namespace System::Windows::Forms;
using namespace System::Runtime::InteropServices;
namespace MCPP
{
        [InterfaceTypeAttribute(ComInterfaceType::InterfaceIsDual)]
        public __gc __interface IMyInterface
        {
                void HelloWorld();
        };
        [ClassInterface(ClassInterfaceType::None)]
        public __gc class MyClass : public IMyInterface
        {
        public:
                void HelloWorld()
                {
                        Form* fm = new Form();
                        fm->Show();
                }
        };
}

Here are two links you may take a look.
http://groups.google.com/groups?hl=zh-CN&lr=&c2coff=1&threadm=mTfn46d2CHA.18
76%40cpmsftngxa06&rnum=2&prev=/groups%3Fhl%3Dzh-CN%26lr%3D%26c2coff%3D1%26q%
3Dimplement%2Binterface%2Bmc%252B%252B
 
http://groups.google.com/groups?hl=zh-CN&lr=&c2coff=1&threadm=a5ebf44c.02123
01430.42609045%40posting.google.com&rnum=5&prev=/groups%3Fhl%3Dzh-CN%26lr%3D
%26c2coff%3D1%26q%3Dimplement%2Binterface%2Bmc%252B%252B

Although the MC++ IDE did not did all the job as C# do, but we still can do
the similar job with C#.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.



Relevant Pages

  • Re: Friend modifier
    ... > Yeah, but then you could almost just declare them public... ... want to expose to the outside world. ... namespace. ... I find these kinds of situations crop up more often than the situation ...
    (microsoft.public.dotnet.framework)
  • Re: can I wait an event object in a different driver?
    ... Just b/c you can put anything you want in any namespace ... the UM app creates the events and passes the handle to the driver. ... the UM sends an IOCTL which the driver pends. ... > what if i dont want to expose my events to user mode (i dont want to ...
    (microsoft.public.development.device.drivers)
  • Re: Elegant way to do this?
    ... > cin or wahtever is preceeded by a namespace resolution ... To then expose all names within the namespace, ... and have exposed the entire 'std' namespace. ... Will my code compile? ...
    (alt.comp.lang.learn.c-cpp)
  • Re: DNS dfs issue
    ... But maybe there is a phantom folder in the namespace. ... It seems to depend on the dns, but they should be the same. ... every client at Site B is affected. ... No matter which dns server I use on clientB1 its %logonserver% is always ...
    (microsoft.public.windows.server.dns)
  • RE: Problem with C# Using Statement on Web Services Proxy
    ... client application through the VS.NET 2005 beta IDE. ... >From the code snippet you provided, the namespace you imported are correct. ... longer use the beta products and move onto the released version. ... | statements that cause compile errors in Visual Studio .NET beta 2: ...
    (microsoft.public.dotnet.framework.aspnet.webservices)