zoukankan      html  css  js  c++  java
  • COM inerop 创建自定义互操作集 问题

    1.如果com是由.net实现

    则在用自定义互操作集时,会发生类型转换错误。如下:

    [ComImport]
       [Guid("06521B83-FDE4-4882-9E29-3812D6A59AA8")]
        class NetComponentWraper
       {

       }

       [ComImport]
       [CoClass(typeof(NetComponentWraper))]
       [Guid("038AFEB5-A5B9-4944-8B3F-BA031A12797A")]
       public interface IWelcomeWraper
       {
           //[DispId(60040)]
           string Greeting(string name);
       }

       class Program
       {


           static void Main(string[] args)
           {
               NetComponentWraper netComponent = new NetComponentWraper();

               IWelcomeWraper welcome = netComponent as IWelcomeWraper;
               welcome.Greeting("asdf");
           }
       }

    转换错误:
    image

    2.另一个问题,如何添加COM事件?

  • 相关阅读:
    数组的push()、pop()、shift()和unshift()方法
    Javascript的函数柯里化
    开闭原则
    字符串相等的判断
    String类常用的方法
    阅读API文档
    String类和常量池
    String基础
    内部类的分类
    内部类的概念
  • 原文地址:https://www.cnblogs.com/cppss/p/3808246.html
Copyright © 2011-2022 走看看