导航

yaosansi's Blog

当你背向太阳的时候,你只会看到自己的阴影!能力是有限的,努力无限的!

« GridView Tips and Tricks using ASP.NET – Part III.Net线程问题解答 »

Active X importer -- AxImp.exe (.Net Framework Tools Series)

  • 本站大部分内容从网上收集,收集目的仅供研究、学习。涉及版权或不希望收录您的文章请您及时与我联系。
  • 本站IM群,请自行选择。请各位朋友按照自己喜好加入。加入群后请及时发言,防止被清理。谢谢您的合作!!!
  • QQ群:Y①WEB开发(ASP.NET)号码:7351660 QQ群:Y②WEB开发(ASP+.NET)号码:11864905
  • QQ群:Y③WEB开发(DIV+CSS)号码:16610506 QQ群:Y④WEB开发(JS+AJAX)号码:16143998
  • QQ群:Y⑤WEB开发(新手)号码:12777715 MSN群:yaosansi[at]126.com
 

原文:http://www.mail-archive.com/dotnetusergrouphyd@groups.msn.com/msg04420.html

Aximp is a tool which is shipped with .Net Framework where Ax stands for Active X and imp for importer. This tool is used to convert Active X control to a windows form control. The .NET equivalent of ActiveX controls are Windows Forms controls. This tool actually creates a wrapper around the Active X control so that it can used from .NET (i.e. managed code). It basically creates an Active X interop assembly.

This wrapper class is derived from System.Windows.Forms.AxHost. This wrapper control contains an instance of the underlying ActiveX control and has access to all its properties and events. To host any Active X control on a Win Form it is necessary to extend it from Axhost class.

There are several ways by which you can use Active X components in the .NET. One of the ways would be adding the active component to your toolbox directly as follows :-

1. Right click on the tool box .
2. Select customize tool box.
3. Select the COM component.
4. Drag and drop the Active X control on your form.

You will see that .NET Studio has generated an interop assembly (solution explorer) for the selected active X control. Now you can  use this control seamlessly as you would have used any other .NET component.

We will create this same interop using Aximp.exe.

Go to the visual studio command prompt and type aximp.exe /h. This will display all the options available with Active X importer.

Setting environment for using Microsoft Visual Studio 2008 x86 tools.
 
D:\Program Files\Microsoft Visual Studio 9.0\VC>aximp.exe/h
Microsoft (R) .NET ActiveX Control to Windows Forms Assembly Generator
[Microsoft .Net Framework, Version 2.0.50727.1434]
Copyright (c) Microsoft Corporation.  All rights reserved.
 
 
Generates a Windows Forms Control that wraps ActiveX controls defined in the giv
en OcxName.
 
Usage:
   AxImp OcxName [Options]
Options:
   /out:FileName            File name of assembly to be produced
   /publickey:FileName      File containing strong name public key
   /keyfile:FileName        File containing strong name key pair
   /keycontainer:FileName   Key container holding strong name key pair
   /delaysign               Force strong name delay signing
                            Used with /keyfile, /keycontainer or /publickey
   /source                  Generate C# source code for Windows Forms wrapper
   /rcw:FileName            Assembly to use for Runtime Callable Wrapper rather
than generating new one.
                            Multiple instances may be specified. Current directo
ry is used for relative paths.
   /nologo                  Prevents AxImp from displaying logo
   /silent                  Prevents AxImp from displaying success message
   /verbose                 Displays extra information
   /? or /help              Display this usage message

To create a interop for an active component you need to type the name of the component ( make sure you in the same directory as your Active X component is ... else type the whole path).

e.g. C:\WINNT\system32>aximp comdlg32.ocx (This is VB's common dialog Active X control)

This will generate interop assemblies for the selected active X control as shown below.

Generated Assembly: C:\WINNT\system32\MSComDlg.dll
Generated Assembly: C:\WINNT\system32\AxMSComDlg.dll

You will notice that there are 2 assemblies that are generated, but one prefixed with Ax. The second one that is the one which is  prefixed with Ax is the Active X Assembly and the first one is the Interop assembly.

The Interop assembly made by tlbimp is same as the one made by aximp.

Open the AxMSComDlg.dll with ildasm and notice that it extends System.Windows.Forms.Axhost class which is required to host an Active X control in a winform.

原创文章如转载,请注明:转载自http://www.yaosansi.com
订阅本站,阅读更多文章

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-Blog .Theme from Google黑板报 By Washun

Copyright 2005-2008 yaosansi'site All Rights Reserved.

感谢Denny·G 为本站提供FTP空间
辽ICP备05021434号

Search

  •  

赞助商广告

控制面板

最新评论及回复

最近发表