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事件?

posted on 2014-06-25 15:59  子清  阅读(173)  评论(0编辑  收藏  举报