views:

242

answers:

1

Is it possible to create a Windows Service (background apps accessible in services.msc) application and host an ASP.NET WebService or a Silverlight compatible WebService within it?

I want to create a WebService that performs COM interop calls to something and decided that a Windows Service that interfaces with COM directly as well as hosting the WebService would be the most flexible way to go. I can then create a ASP.NET website and Silverlight application to interact with the WebService.

The other way is to have the ASP.NET perform the COM interop calls on the server side but how safe is this and does .NET even allow that?

+1  A: 

You cannot host an ASMX web service in a Windows Service. You can, and should, do it with WCF, which replaces ASMX.

On the other hand, there's no reason you can't use COM interop in an ASP.NET application, as easily as you can with any other .NET application. The only thing to be aware of is multithreading; since it will be called from a service, your COM object will be getting called on multiple threads, which it may not expect.

John Saunders