views:

268

answers:

1

Hi,

I have a windows application that has its business logic layer implemented as a WCF service. This service is currently hosted on IIS. I wanted to know that if there's a way where I could optionally run the application in standalone mode when a service isn't available/feasible.

+1  A: 

In proper design, the business logic really shouldn't be implemented as a WCF service directly - it should abstracted out into a separate assembly for reasons just like yours, and the WCF wrapper should instead simply reference it. I'm guessing you didn't have a say in this non-orthogonal design.

If you have access to the WCF assemblies, you could distribute them with your standalone application and reference them, and then call into those WCF operations without activating it as a service. It would be rather ugly but it would work, assuming none of the business logic depends on any WCF-activated features.

edit re comments: You can have multiple service hosts and endpoints and keep the same contract ("interface") in WCF. Perhaps you want to add some self hosting that exposes a named pipe endpoint, and access the operations that way in your application.

Mike Atlas
@Mike. Thank you for the answer. The reason I don't want to refer the business logic assemblies directly is because I want to keep the interface of communication between the application and the service common for both scenarios.
Ali Kazmi
@Mike I think I wasn't able to communicate my problem accurately. Maybe the solution I went for will make it clear. I embedded an http server into my application to host the service in case if a remote server isn't specified. I wanted to make no direct references to the service assembly or the objects being passed around.
Ali Kazmi
Yes, so you did self-host :) Cool.
Mike Atlas