Friday, September 3, 2010
Written by: animesh Total Posts: 222
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
15 views
animesh

Learn Using ActiveX Control in .Net

Tagged with:
Thursday, December 25, 2008, 9:14
This news item was posted in Jobs, Stay Ahead category and has 0 Comments so far.

Using ActiveX Control in .Net

ActiveX control is a special type of COM component that supports a
User Interface. Using ActiveX Control in your .Net Project is even
easier than using COM component. They are bundled usually in .ocx
files. Again a proxy assembly is made by .Net utility AxImp.exe
(which we will see shortly) which your application (or client) uses
as if it is a .Net control or assembly.
Making Proxy Assembly For ActiveX Control: First, a proxy assembly
is made using AxImp.exe (acronym for ActiveX Import) by writing
following command on Command Prompt:
C:>AxImp C:MyProjectsMyControl.ocx
This command will make two dlls, e.g., in case of above command
MyControl.dll
AxMyControl.dll
The first file MyControl.dll is a .Net assembly proxy, which allows
you to reference the ActiveX as if it were non-graphical object.
The second file AxMyControl.dll is the Windows Control, which allows
u to use the graphical aspects of activex control and use it in the
Windows Form Project.
Adding Reference of ActiveX Proxy Assembly in your Project Settings:
To add a reference of ActiveX Proxy Assembly in our Project, do this:
o Select ProjectàAdd Reference (Select Add Reference from Project
Menu).
o This will show you a dialog box, select .Net tab from the top of
window.
o Click Browse button on the top right of window.
o Select the dll file for your ActiveX Proxy Assembly (which is
MyControl.dll) and click OK o Your selected component is now shown
in the `Selected Component’ List Box. Click OK again Some More On
Using COM or ActiveX in .Net
.Net only provides wrapper class or proxy assembly (Runtime Callable
Wrapper or RCW) for COM or activeX control. In the background, it is
actually delegating the tasks to the original COM, so it does not
convert your COM/activeX but just imports them.
A good thing about .Net is that when it imports a component, it also
imports the components that are publically referenced by that
component. So, if your component, say MyDataAcsess.dll references
ADODB.dll then .Net will automatically import that COM component
too!
The Visual Studio.NET does surprise you in a great deal when u see
that it is applying its intellisense (showing methods, classes,
interfaces, properties when placing dot) even on your imported COM
components!!!! Isn’t it a magic or what?
When accessing thru RCW, .Net client has no knowledge that it is
using COM component, it is presented just as another C# assembly.
U can also import COM component thru command prompt (for reference
see Professional C# by Wrox) U can also use your .Net components in
COM, i.e., export your .net components (for reference see
Professional C# by Wrox)

You can leave a response, or trackback from your own site.

Leave a Reply