You'll have to perform a number of steps that are normally taken of automatically when you use the toolbox.

First and foremost, you have to run the Aximp.exe utility to generate the .NET interop assemblies. Use the Visual Studio Command Prompt to run the tool. You'll get two assemblies, axinterop.foo.dll contains a wrapper class that's derived from AxHost and allows you to put the control on a form. And interop.foo.dll, the interop assembly that makes the COM interfaces implemented by the control callable from a .NET program.

Next you have to ensure these DLLs are present in the build directory. Best thing to do is to add them to your project and set their Copy to Output Directory to "Copy if newer".

Now you can use Assembly.Load("axinterop.foo.dll") in your code to dynamically load the interop assembly.

Next you have to create an instance of the control, use Assembly.CreateInstance() and pass the type name of the AxHost wrapper class. If you have no idea what its name might be, it isn't obvious, then use ildasm.exe to look at the axinterop.foo.dll assembly. Cast the returned object to AxHost.

Next you have to add the control to the form's Controls collection so it is visible and usable. You cannot call any interface methods until the control instance is created, that doesn't happen until you've added the control and the form's Load event has fired.

Next you have to use reflection or the dynamic keyword to obtain a reference to the interfaces implemented by the control, in case you need to set properties or call methods. That's difficult to get right, you'll want to write that code first with the control added from the toolbox so you don't have to guess too hard at the proper names.

最新文章

  1. weedfs getsockopt: connection timed out
  2. java执行效率低,但效率就低吗?
  3. git入门学习(二):新建分支/上传代码/删除分支
  4. 如何让JQuery报错-遁地龙卷风
  5. Spring对象绑定与类型转换
  6. ArcGIS中的style样式的使用
  7. 修改mysql root 密码
  8. 解读XMP元数据中ALAssetRepresentation
  9. gitlab 启动参考
  10. java 类型转换:
  11. NYOJ 10 skiing动态规划心得
  12. Python 数据分析(一) 本实验将学习 pandas 基础,数据加载、存储与文件格式,数据规整化,绘图和可视化的知识
  13. 原码,反码,补码 与(&) 或(|) 非(~) 异或(^) 左移 << 右移 >> 无符号右移 >>>
  14. linux web服务器及LAMP动态网站平台搭建
  15. 使用Rancher的RKE快速部署Kubernetes集群
  16. ERP、CRM、CMS
  17. Accounting_会计基础
  18. 自创open vp n windows步骤
  19. C#中命名空间别名的使用
  20. awk练习

热门文章

  1. 网络监控之一:netstat命令
  2. 1130 Infix Expression
  3. Cassandra学习六 一些知识点
  4. cassandra学习 四 数据模型
  5. Linux 命令初识
  6. 委托BegionInvoke和窗体BegionInvoke
  7. 泛型集合List<T>
  8. keil的使用:新建Project
  9. 前端自动化之npm
  10. Mycat主从模式下的读写分离与自动切换