|
|
Using automation in C#
In this paper I will show how to use automation servers in a C#
application. If you are not familiar with COM, OLE, automation, ActiveX or
whatever you name it, and you know some Delphi you will find more on my Delphi
pages.
COM's not dead !
Now we have .NET you will hear people scream : "COM is dead". I
don't think this is true, COM will play an important role in Windows software
for years to come. Just think of the following:
- Existing software like JavaScript, VBscript, Internet Explorer and Office
is very COM aware and does not understand anything at all about .NET
objects. New features in this software, for instance the smart tags in
Office XP, are still implemented using COM.
- No piece of software is an island. COM is a well defined protocol which is
broadly understood and can play a great role in the communication between
.NET - and "legacy" - software.
- The support for COM in .NET is great. Most of the possibilities are hidden
in the doc's and are not given much attention. This is where this website
will try to play a role.
A C# automation client
Automation objects can be used by C#. The code in the implementing library
does not have the advantages of native C#. The code is unaware of .NET's common
type system and is not type safe at all. It is called unmanaged code in .NET.
The runtime does a lot to isolate the automation DLL from the C# code, using
things like the COM callable wrapper. All of this happens behind the scenes and
can be taken for granted for the moment.
In my series on building automation objects
using Delphi I have used C# to build a client for my Delphi built automation
DLL. Read all about it.
Where are we ?
The support for automation objects in C# is very good. The automation class
is referenced by the application just like it references parts of the .NET
framework. After which all properties and methods as well as powerful helper
methods are available like any other .NET class. Which makes automation
transparent to a C# client.
What's next
|