DekGenius.com
Team LiB
Previous Section Next Section

What about COM?

With ASP web applications, the only way to compile and encapsulate business logic was to use COM components. COM components are also used in Visual Basic to add additional features and functions. Let’s look at how .NET helps with migration of applications using COM components.

Most COM components that work in ASP will work in ASP .NET. Late-bound calls are still supported using Server.CreateObject; however, for better performance, it is recommended that early-bound calls are used. Before you can use a COM component in .NET, you must first expose the component in .NET assemblies. With Visual Studio.NET, this is very easy: You simply add a COM reference to your project, and the rest is automatically taken care of for you. If you are only using the .NET SDK, you can use the Type Library Importer (TlbImp.exe). Type Library Importer converts standard COM components to the equivalent .NET Framework interoperations (InterOp) assemblies by building managed wrappers around the components.

.NET Framework Bidirectional Migration Support

So far, we have seen how to allow .NET applications to use existing COM components. What if we need to migrate the COM component itself but still want to use it in existing ASP and Visual Basic applications? Can .NET help? The answer to this is, of course, yes. The .NET InterOp services offer bidirectional support. It means that .NET components through InterOp service can be exposed as COM components. The System.Runtime. InteropServices namespace provides three categories of interop-specific attributes that you can use. However, I will not go into more detail because this is beyond the scope of this book.

Note 

It is far easier to expose COM to .NET than to expose .NET as COM.

ASP and ASP .NET

Since ASP and ASP .NET uses different run times on the same server, the two can co-exist even within the same web application. This is usually while migration is in progress. You can slowly convert the ASP pages to ASP .NET, and the users can immediately get the benefits of the change.

Team LiB
Previous Section Next Section