The Perfect Service - Part 2
page 5 of 6
by J. Ambrose Little
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 28225/ 50

Bring 'Em Down

Of course, the flip side of this is what is required to stop a managed service. Fortunately, this is much simpler because we have already done all the hard work. When a managed service assembly is deleted or when a user chooses to stop the .NET Service Manager in the Services applet, a call is made to ServiceBroker's StopService method (Listing 10). This method, as you will see, takes a file path of the managed service to stop and uses that to look up it up in the service names cache. If found, it will call the UnloadService method, which we already covered in Listing 4, and then remove it from the service names cache. Ah, if only it were all so simple!

Listing 10 – StopService

if (this.serviceNames.Contains(filePath))
{
      this.UnloadService(Convert.ToString(this.serviceNames[filePath]));
      this.serviceNames.Remove(filePath);
}

So now you've seen most of what's involved to give the .NET Service Manager its magic. Obviously, most of this, especially the concepts surrounding AppDomains, Remoting, and Reflection, could be very useful in any application where you want to enable such cool features as dynamic loading, updating, and unloading of assemblies.


View Entire Article

User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 11:56:00 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search