Integrating WCF Services with COM+ Chris Peiris (AvanadeAustralia, www.ChrisPeiris.com) Shawn Cicoria (www.CedarLogic.com) February 2007 Revised August 2007 Applies to: Microsoft .NET Framework 3.0 Windows Vista Microsoft Internet Information Services Microsoft Visual Studio 2005 Summary: This article will detail step by step instructions to consume COM+ application services from WCF clients.
We will also discuss how legacy applications can use applications that expose WCF services built on .NET 3.0. The content for this article is based on Chapter 10 of Pro WCF : Practical Microsoft SOA Implementation by APress. Download QuickReturns case study description Contents Introduced in 1993, Component Object Model (COM) was the basis for other emerging technologies from Microsoft such as Object Linking and Embedding (OLE), ActiveX, and Distributed COM (DCOM). COM+, introduced in 1998, was more of ancillary technology that was built on COM but did not replace it.
Today, COM+ 1.5 is a core part of the Windows platform. Figure 10-1. Building COM Objects in C# Introduction The topics covered in this article are: Creating a simple COM object in C# (use the COM Interop property).
Accessing the COM from a VC++ client. (I have tested it with VC++6.0 and VC++ .NET). Client uses the TypeLibrary (.TLB file). For the sake of simplicity and ease of use for the developers, testing this code, I have used the Northwind database built into with the default installation of SQL Server database. Modify the name of the SQL Server in the COM object to connect to your SQL Server. Part I: Creating a simple COM object in C# COM objects are of the type ClassLibrary. New->Project->Visual C# Projects ->Class Library Create a project named Database_COMObject. Remember: Exposing the VC# objects to the COM world requires the following ... The class must be public.
Other public members in the class that are not declared in these interfaces will not be visible to COM, but they will be visible to other .NET Framework objects. Here is how the interface class looks like ... Creating COM Components using Visual C#.NET. Developers are sometimes asked to support older software systems that utilize obsolete technologies.
This may be difficult when the development tools used to implement the older software system are not available and have been replaced by newer tools that do not seem to support the former tools’ technologies. Faced with the need to replace a COM component that is used by VBScript in an ASP application, a developer may need to create the replacement using Visual Studio .NET. This guide is motivated at helping developers create COM components using Visual Studio.NET and C#. Creating the COM Object Launch Microsoft Visual Studio .NET and create a new Visual C# Project with the Empty Project template.
Testing the COM Object Test procedures for the COM object that was created above: Create a file called “test.vbs.”Place the following into test.vbs: dim o set o = createobject( "COMTest.COMObject" ) Wscript.Echo o.COMObjectFunction Execute test.vbs. COM Interop Part 1: C# Client Tutorial (C#) COM Interop provides access to existing COM components without requiring that the original component be modified.
When you want to incorporate COM code into a managed application, import the relevant COM types by using a COM Interop utility (TlbImp.exe) for that purpose. Once imported, the COM types are ready to use. In addition, COM Interop allows COM developers to access managed objects as easily as they access other COM objects. Again, COM Interop provides a specialized utility (RegAsm.exe) that exports the managed types into a type library and registers the managed component as a traditional COM component.
At run time, the common language runtime marshals data between COM objects and managed objects as needed. This tutorial shows how to use C# to interoperate with COM objects. Sample Files Further Reading Tutorial C# uses .NET Framework facilities to perform COM Interop. Creating COM objects. This tutorial covers the following topics: Creating a COM Class Wrapper.