WPF 添加ACTIVEX 控件 ——System.Windows.Forms.AxHost+InvalidActiveXStateException异常

---恢复内容开始---

一、ACTIVEX及其相关概念

COM(Component Object Model,对象组件模型);
DCOM(Distributed COM,分布式对象组件模型);
CORBA(Common Object Request Broker Architecture,公共对象请求代理体系结构);
 
动态数据交换(Dynamic Data Exchange,DDE),解决了数据的更新,但数据格式仍是问题;
对象的链接与嵌入(Object Linking and Embedded,OLE),数据交换提高到“对象交换”;
ActiveX是指宽松定义的、基于COM的技术集合,而OLE仍然仅指复合文档;ActiveX和OLE的最大不同在于,OLE针对的是桌面上应用软件和文件之间的集成,而 ActiveX则以提供进一步的网络应用与用户交互为主。
 
二、WPF 加入ACtiveX 控件

  使用 WindowsFormsHost 元素可将 Windows Forms控件放置到 WPF 元素或页面中。

  若要在 Windows Forms控件或窗体中承载 WPF 元素,使用 ElementHost控件

1.添加引用 WindowsFormsIntegration ;
 
2.创建 WindowsFormsHost 对象

        System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();

3.实例化Activex控件 、初始化控件、控件复值到host 

  txsl1 = new activex();

  host.Child = txsl1;

4.添加Host对象到WPF 窗体

      this.mainGrid.Children.Add(host);

---恢复内容结束---

posted @ 2016-03-15 11:34  cdxy2005  阅读(2041)  评论(0编辑  收藏  举报