.net AxInterop 和 Interop 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2287839/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 13:56:12  来源:igfitidea点击:

What is the difference between AxInterop and Interop?

.netcominteropactivexocx

提问by Yaron Naveh

I've added an .ocx to the toolbox in VS. Two .dll's were created: Interop.NNN.dll, AxInterop.NNN.dll.

我在 VS 的工具箱中添加了一个 .ocx。创建了两个 .dll:Interop.NNN.dll、AxInterop.NNN.dll。

What is each one? Are they both required?

每一个是什么?两者都需要吗?

采纳答案by Hans Passant

The AxFoo.dll assembly contains an automatically generated class that's derived from the System.Windows.Forms.AxHost control. It is pretty simple, it has methods, properties and events, the same ones you have available in the .ocx, that simply call the Foo.dll interop library.

AxFoo.dll 程序集包含一个从 System.Windows.Forms.AxHost 控件派生的自动生成的类。它非常简单,它具有方法、属性和事件,与您在 .ocx 中可用的相同,只需调用 Foo.dll 互操作库。

So, yes, you definitely need to deploy both assemblies.

所以,是的,您肯定需要部署这两个程序集。

回答by Adriaan Stander

Interop.xxx.dll and AxInterop.xxx.dll are runtime callable wrappers (RCW) for a referenced COM and an ActiveX dll respectively.

Interop.xxx.dll 和 AxInterop.xxx.dll 分别是引用的 COM 和 ActiveX dll 的运行时可调用包装器 (RCW)。

interop.xxx.dll is purely an automation (a COM dll) wrapper, enabling you to manipulate the object within the namespace of your application. AxInterop.xxx.dll is a control wrapper for a ActiveX control, which can be dragged onto the form.

interop.xxx.dll 纯粹是一个自动化(COM dll)包装器,使您能够操作应用程序命名空间内的对象。AxInterop.xxx.dll 是 ActiveX 控件的控件包装器,可以将其拖到窗体上。