Queued Components Sample | (Windows Forms Application) |
This document contains the release information for the .NET Framework Queued Components sample. You will find the following sections below:
Queued Components is a COM+ feature built on top of Message Queueing Services (MSMQ) that provides a mechanism for invoking and executing components asynchronously. When a client makes a call to a queued object, the call is actually made to a recorder, which packages it as a message and places that message in a queue. A listener reads the message from the queue and passes it to the player. The player makes the actual method calls on the server object.
In order for the server to receive queued messages, it must be activated in some way. Server components can be activated manually, using scripting in combination with the task scheduler, or programmatically. In this sample, we will activate the server component manually.
The sample code consists of a client application and a managed object that is marked for InterfaceQueueing. The listener is enabled by means of a class attribute. On building the application, COM+ creates a queue whose name is the same as the specified COM+ application.
The client application contains a single button. Clicking the button invokes the queued component recorder by means of a queue moniker. All calls through the returned reference are packaged and placed in the appropriate message queue.
Queued method calls will be unpackaged and delivered to the actual server component when it is activated in the Component Services administrative tool. The sample server displays a simple message box to show that the call has made it to the server.
The following bullets briefly describe the technologies used by this sample.
This sample is located in the Technologies\ComponentServices\QueuedComponents subdirectory of the .NET Framework SDK samples directory.
For Example:
C:\Program Files\Microsoft.NET\SDK\v1.1\Samples\Technologies\ComponentServices\QueuedComponents
In order to properly build and run this sample, the following steps need to be performed.
IMPORTANT: in order to build and execute this sample, MSMQ must be installed on your computer in Workgroup mode.
Double-click My Computer\Control Panel\Add/Remove Programs.
In the Add/Remove Programs dialog, click 'Add/Remove Windows Components' and check the item labeled 'Message Queuing Services'. Click 'Next'.
Windows 2000 has additional steps to install MSMQ:
In the subsequent 'Message Queuing Type' wizard page, click the checkbox labeled 'Manually select access mode to Active Directory'. Click 'Next'.
In the subsequent 'Message Queuing Server' page, click the radio button labeled 'Message Queuing will not access a directory service'. Click 'Next' and setup will complete. Click 'Finished'.
After installing MSMQ, build the sample code by typing BuildAll.bat from the command line.
For Example:
C:\Program Files\Microsoft.NET\SDK\v1.1\Samples\Technologies\ComponentServices\QueuedComponents>buildall.bat
If you're building the sample from Visual Studio 7, you will need to register the QCDemoSvr.dll assembly to setup the Message Queue before running the sample. Note: The regsvcs.exe program is located in the %systemroot%\Microsoft.NET\Framework\<version> directory.
For Example:
C:\Program Files\Microsoft.NET\SDK\v1.1\Samples\Technologies\ComponentServices\QueuedComponents\CS>regsvcs QCDemoSvr.dll
you will also need to install the QCDemoSvr.dll assembly to the Global Assembly Cache before running the sample. Note: The gacutil.exe program is located in the SDK\v1.1\Bin directory.For Example:
C:\Program Files\Microsoft.NET\SDK\v1.1\Samples\Technologies\ComponentServices\QueuedComponents\CS>gacutil -i QCDemoSvr.dll
The sample builds a C# and VB version of the client application and COM+ component. Source code for each language is stored in subdirectories named \CS and \VB. The C# component has 'CS' appended to its name as viewed in the Component Services administrative tool, 'QCDemoServerCS.QComponent'. The VB version is named 'QCDemoServerVB.QComponent'. When working with the sample code, be sure to observe and/or modify the version of the COM+ component that corresponds to the client application you launch.
Review comments in the source code and build.bat files for more information on sample binary creation and registration steps.
In order to run this sample, follow the instructions listed below.
For Example:
C:\Program Files\Microsoft.NET\SDK\v1.1\Samples\Technologies\ComponentServices\QueuedComponents\CS>qcdemo.exe
In order to uninstall this sample, follow the instructions listed below.
For the .Net Framework samples to function properly, your Path, Include, and Lib environment variables must be set correctly. In many cases, the SDK install program updates these environment variables for you. However, if you installed the .Net Framework SDK using Visual Studio .NET, or unselected "register environment variables" during setup, these environment variables will not be updated. You can set the Path, Include and Lib environment variables by running SDKVars.bat, located in the <SDKRoot>\Bin directory. SDKVars.bat must be executed in every command shell.