Client Application C# Help

After building the serviced component library, you can create a client application. This can be as simple as a C# console application. After you’ve created the project for the client, you have to reference both the assembly from the serviced component, SimpleServer, and the assembly System. EnterpriseServices. Then you can write the code to instantiate a new_simpleComponent instance and invoke the method Welcome() . In the following code, the Welcome () method is called 10 times. The using statement helps to release the resources allocated with the instance before the garbage collector takes action. With the using statement, the Dispose() method of the serviced component is called when the scope of the using statement ends.

If you start the client application before configuring the server, the server will be configured automatically. The automatic configuration of the server is done with the values that you’ve specified using attributes. For a test you can unregister the serviced component and start the client again. If the serviced component is configured during the start of the client application, the startup needs more time.
Remember that this feature is useful only during development time. Administrative rights are also needed for automatic deployment. If you are starting the application from within Visual Studio, that means you should start Visual Studio with administrative rights.

While the application is running, you can monitor the serviced component with the Component Services Explorer. By selecting Components in the tree view and choosing View ¢ Detail, you can view the number of instantiated objects if the attribute [EventTrackingEnabled] is set.

As you’ve seen, creating serviced components is just a matter of deriving the class from the base class ServicedComponent and setting some attributes to configure the application. Next, you see how transactions can be used with serviced components.

Posted on October 31, 2015 in Enterprise Services

Share the Story

Back to Top
Share This