- Designing COM+ Applications with a Web Service Appeal
- Creating the COM+ Application
- Defining the Web Service
- Using the Web Service from .NET
Creating the COM+ Application
Now that you have a component to test with COM+, it's time to create the COM+ application. This is a two step process. First, you create the COM+ application, Then you add the component to it. However, when working with .NET components, you need to exercise a little extra care, because sometimes the component will appear to register without problem, but you can't access the methods due to any of a number of errors.
To start the process, create a COM+ application. Because we want to expose this application as a Web service, you have to make it a server application. Begin the process by opening the Component Services console located in the Administrative Tools folder of the Control Panel. Right click the Console Root\Component Services\Computers\My Computer\COM+ Applications folder and choose New | Application from the context menu. You'll see the COM+ Application Install Wizard.
It's time to create the COM+ application. Click Next so you see the Install or Create a New Application dialog box. Click Create an Empty Application, because we're creating a new application. In the Create Empty Application dialog box you supply an application name (the example uses COMPlusTest) and define an application type (it must be Server Application). Follow the rest of the prompts using the default options.
You're now the proud owner of a new COM+ application. However, this application doesn't have any components in it, so it won't do anything. Open the application, and right click the Components folder. Select the New | Component option from the context menu. You'll see the COM+ Component Install Wizard.
Let's add a new component. Click Install New Component. You'll see a Select Files to Install dialog box. Highlight the type library (TLB file) created by RegAsm, and click Open. At this point, you'll see the Install New Components dialog box. Notice that it contains the name of the component and the component status, as shown in Figure 2.
Figure 2: Check the component name and status to ensure it installed correctly.
It's important to check this dialog box carefully because it can tell you whether the .NET component installed successfully. Make sure you check the component name to ensure it's correct. Also check whether COM+ found the interfaces. Errors in this dialog box usually indicate that RegAsm didn't work correctly (you had the wrong switches) or the component is missing one or more [ComVisible(true)] entries. Once you verify the entries, follow the rest of the prompts to add the component.
Now you can verify the COM+ application setup. Open the Interfaces, look for
ISimpleMath, and check out the methods. Your application should match the one shown in Figure 3. When any of the interfaces or methods are missing, it usually indicates some type of error in your code, such as missing [ComVisible(true)] entries or an invalid [ClassInterface(ClassInterfaceType.AutoDual)] entry.
Figure 3: Verify the application setup is correct.