怎么把C#编写的dll程序注册为com组件,供MFC调用啊,急!!!

解决方案 »

  1.   

    C#编写COM组件 
      

  2.   

    VC6.0和VS2005:C++和C#编写调用COM组件
      

  3.   

    给你个我测试的例子:[ComVisible(true)]
      public interface IMath
      {
      [DispId(1)]
      int Add(int a, int b);  [DispId(2)]
      int Sub(int a, int b);
      }[ComVisible(true)]
      [ClassInterface(ClassInterfaceType.None)]
      public class Dotnet :ServicedComponent, IMath
      {
      #region IMath 成员  public int Add(int a, int b)
      {
      return a+b;
      }  public int Sub(int a, int b)
      {
      return a - b;
      }  #endregion
      }
      

  4.   

    C++调用Com组件,这个你会吗?
      

  5.   

    可以看这个链接:http://developer.51cto.com/art/200907/133668.htm
      

  6.   

    还有这个,希望对你有帮助。http://developer.51cto.com/art/200909/153811.htm
      

  7.   

    我在网上查的是 stdafx.h中 添加
     #import "AchievementShow.tlb"
    using namespace AchievementShow
    但是我写的using 这一句总是出错:“AchievementShow”: 具有该名称的命名空间不存在还有这一句 MyCom::MyCom_InterfacePtr p(__uuidof(MyCom::Class1));  是什么意思?请详细讲解一下
                                
      

  8.   

    LZ,你现在的问题跟C#一点关系也没有,好好看看《COM本质论》,了解COM如何创建和使用。