Aximp.exe(Windows 窗体 ActiveX 控件导入程序)Aximp.exe (Windows Forms ActiveX Control Importer)

ActiveX 控件导入程序将 ActiveX 控件的 COM 类型库中的类型定义转换为 Windows 窗体控件。The ActiveX Control Importer converts type definitions in a COM type library for an ActiveX control into a Windows Forms control.

Windows 窗体只能承载 Windows 窗体控件,即从 Control 派生的类。Windows Forms can only host Windows Forms controls — that is, classes that are derived from Control. Aximp.exe 生成可承载于 Windows 窗体上的 ActiveX 控件的包装器类。Aximp.exe generates a wrapper class for an ActiveX control that can be hosted on a Windows Form. 这使你得以使用适用于其他 Windows 窗体控件的同一设计时支持和编程方法。This allows you to use the same design-time support and programming methodology applicable to other Windows Forms controls.

若要承载 ActiveX 控件,必须生成从 AxHost 派生的包装器控件。To host the ActiveX control, you must generate a wrapper control that derives from AxHost. 此包装器控件包含基础 ActiveX 控件的一个实例。This wrapper control contains an instance of the underlying ActiveX control. 它知道如何与 ActiveX 控件通信,但它显示为 Windows 窗体控件。It knows how to communicate with the ActiveX control, but it appears as a Windows Forms control. 这个生成的控件承载 ActiveX 控件并将其属性、方法和事件作为生成的控件的属性、方法和事件公开。This generated control hosts the ActiveX control and exposes its properties, methods, and events as those of the generated control.

此工具会自动随 Visual Studio 一起安装。This tool is automatically installed with Visual Studio. 若要运行此工具,请使用 Visual Studio 开发人员命令提示(或 Windows 7 中的 Visual Studio 命令提示)。To run the tool, use the Developer Command Prompt for Visual Studio (or the Visual Studio Command Prompt in Windows 7). 有关详细信息,请参阅命令提示For more information, see Command Prompts.

在命令提示符处,键入以下内容:At the command prompt, type the following:


aximp [options]{file.dll | file.ocx}  


参数Argument 说明Description
文件 file 包含要转换的 ActiveX 控件的源文件的名称。The name of the source file that contains the ActiveX control to convert. 文件参数中必须具有扩展名 .dll 或 .ocx。The file argument must have the extension .dll or .ocx.
选项Option 说明Description
/delaysign 指定 Aximp.exe 使用延迟的签名对生成的控件进行签名。Specifies to Aximp.exe to sign the resulting control using delayed signing. 必须使用 /keycontainer:/keyfile:/publickey: 选项指定此选项。You must specify this option with either the /keycontainer:, /keyfile:, or /publickey: option. 有关延迟签名过程的更多信息,请参见延迟为程序集签名For more information on the delayed signing process, see Delay Signing an Assembly.
/help 显示该工具的命令语法和选项。Displays command syntax and options for the tool.
/keycontainer: containerName /keycontainer: containerName 使用在 containerName 指定的密钥容器中找到的公钥/私钥对,对生成的控件进行强名称签名 。Signs the resulting control with a strong name using the public/private key pair found in the key container specified by containerName.
/keyfile: filename /keyfile: filename 使用在 filename 中找到的发行者的正式公钥/私钥对,对生成的控件进行强名称签名 。Signs the resulting control with a strong name using the publisher's official public/private key pair found in filename.
/nologo 取消显示 Microsoft 启动版权标志。Suppresses the Microsoft startup banner display.
/out: filename /out: filename 指定要创建的程序集的名称。Specifies the name of the assembly to create.
/publickey: filename /publickey: filename 使用在 filename 指定的文件中找到的公钥,对生成的控件进行强名称签名 。Signs the resulting control with a strong name using the public key found in the file specified by filename.
/rcw: filename /rcw: filename 使用指定的运行时可调用包装器,而不用生成新的包装器。Uses the specified runtime callable wrapper instead of generating a new one. 你可以指定多个实例。You may specify multiple instances. 当前目录用于相对路径。The current directory is used for relative paths. 有关详细信息,请参阅运行时可调用包装器For more information, see Runtime Callable Wrapper.
/silent 取消显示成功消息。Suppresses the display of success messages.
/source 生成 Windows 窗体包装器的 C# 源代码。Generates C# source code for the Windows Forms wrapper.
/verbose 指定详细模式;显示更多进度信息。Specifies verbose mode; displays additional progress information.
/? 显示该工具的命令语法和选项。Displays command syntax and options for the tool.

Aximp.exe 一次转换整个 ActiveX 控件类型库,并生成一组程序集,这些程序集包含在原始类型库中定义的类型的公共语言运行时元数据和控件实现。Aximp.exe converts an entire ActiveX Control type library at one time and produces a set of assemblies that contain the common language runtime metadata and control implementation for the types defined in the original type library. 生成的文件按照下面的模式命名:The generated files are named according to the following pattern:

COM 类型的公共语言运行时代理:progid.dll common language runtime proxy for COM types: progid.dll

ActiveX 控件的 Windows 窗体代理(其中 Ax 表示 ActiveX):Axprogid.dll Windows Forms proxy for ActiveX controls (where Ax signifies ActiveX): Axprogid.dll


如果 ActiveX 控件的成员名称与 .NET Framework 中定义的名称匹配,则 Aximp.exe 在创建 AxHost 派生类时,将在成员名称前加上前缀“Ctl”。If the name of a member of the ActiveX control matches a name defined in the .NET Framework, Aximp.exe will prefix the member name with "Ctl" when it creates the AxHost derived class. 例如,如果 ActiveX 控件有一个名为“Layout”的成员,由于在 .NET Framework 中定义了 Layout 事件,因此该成员在 AxHost 派生类中将重命名为“CtlLayout”。For example, if your ActiveX control has a member named "Layout," it is renamed "CtlLayout" in the AxHost derived class because the Layout event is defined within the .NET Framework.

可以使用 Ildasm.exe(IL 反汇编程序)之类的工具检查这些生成的文件。You can examine these generated files with tools such as Ildasm.exe (IL Disassembler).

不支持使用 Aximp.exe 为 ActiveX WebBrowser 控件 (shdocvw.dll) 生成 .NET 程序集。Using Aximp.exe to generate a .NET assembly for the ActiveX WebBrowser control (shdocvw.dll) is not supported.

在对 shdocvw.dll 运行 Aximp.exe 时,该工具始终会在运行它的目录中创建另一个名为 shdocvw.dll 的文件。When you run Aximp.exe over shdocvw.dll, it will always create another file named shdocvw.dll in the directory from which the tool is run. 如果将此生成文件放在 Documents and Settings 目录下,则会导致 Microsoft Internet Explorer 和 Windows 资源管理器出现问题。If this generated file is placed in the Documents and Settings directory, it causes problems for Microsoft Internet Explorer and Windows Explorer. 重启计算机时,Windows 会先在 Documents and Settings 目录查找 shdocvw.dll 的副本,然后再在 system32 目录查找。When the computer is rebooted, Windows looks in the Documents and Settings directory before the system32 directory to find a copy of shdocvw.dll. 它将使用在 Documents and Settings 目录中找到的副本,并尝试加载托管的包装器。It will use the copy it finds in Documents and Settings and attempt to load the managed wrappers. 由于 Internet Explorer 和 Windows 资源管理器依赖于 system32 目录中的 shdocvw.dll 版本中的呈现引擎,因此它们将无法正常工作。Internet Explorer and Windows Explorer will not function properly because they rely on the rendering engine in the version of shdocvw.dll located in the system32 directory. 如果出现此问题,请在 Documents and Settings 目录中删除 shdocvw.dll 的副本,然后重启计算机。If this problem occurs, delete the copy of shdocvw.dll in the Documents and Settings directory and reboot the computer.

通过对 shdocvw.dll 使用 Aximp.exe 来创建用于应用程序开发的 .NET 程序集也会导致问题。Using Aximp.exe with shdocvw.dll to create a .NET assembly for use in application development can also cause problems. 在这种情况下,应用程序将同时加载 shdocvw.dll 的系统版本和生成版本,并可能为系统版本赋予更高的优先级。In this case, your application will load both the system version of shdocvw.dll and the generated version, and may give the system version priority. 此时,如果尝试在 WebBrowser ActiveX 控件内加载网页,用户可能会收到打开/保存对话框提示。In this case, when you attempt to load a Web page inside the WebBrowser ActiveX control, users may be prompted with an Open/Save dialog box. 用户单击“打开”后,将在 Internet Explorer 中打开该网页 。When the user clicks Open, the Web page will be opened in Internet Explorer. 此情况只出现在运行 Internet Explorer 版本 6 或更早版本的计算机上。This occurs only with computers that are running Internet Explorer version 6 or earlier. 若要防止此问题,请使用托管 WebBrowser 控件或使用 Visual Studio 生成托管 shdocvw.dll,如如何:添加对类型库的引用中所述。To prevent this problem, use the managed WebBrowser control or use Visual Studio to generate the managed shdocvw.dll as described in How to: Add References to Type Libraries.


下面的命令为媒体播放器控件 msdxm.ocx 生成 MediaPlayer.dll 和 AxMediaPlayer.dll。The following command generates MediaPlayer.dll and AxMediaPlayer.dll for the Media Player control msdxm.ocx.

aximp c:\systemroot\system32\msdxm.ocx  

请参阅See also