servicehost

How to specify ServiceHostFactory for self-hosted WCF service with no SVC file

爱⌒轻易说出口 提交于 2019-12-10 15:19:01
问题 My application runs as a Windows service. It dynamically creates WCF services using the following helper method: public static void StartWebService(string webServiceName, Type serviceContractType, Type serviceImplementationType) { if (string.IsNullOrEmpty(webServiceName)) return; var baseAddress = GetWebServiceAddress(webServiceName); var baseUri = new Uri(baseAddress); lock (RunningWebServices) { if (RunningWebServices.ContainsKey(webServiceName)) return; var webServiceHost = new ServiceHost

WCF ServiceHost basicHttpBinding 503 error

守給你的承諾、 提交于 2019-12-09 03:36:52
问题 I'm trying to run a WCF ServiceHost as an NT Service on a Windows 2007 SP1 Server. The ServiceHost is reponsible for hosting a single service endpoint: a basicHttpBinding with the following address: http://localhost:5555/ToBlah When I run this ServiceHost on my local machine (Windows XP), it works fine - when I POST a SOAP message to it, I get back an HTTP 202 code ("Accepted"), which is the correct response for my service because the contract has IsOneWay=true. However, when I run this on my

WCF: How to stop myServiceHost.Close() from disposing of myServiceHost object?

自作多情 提交于 2019-12-08 15:53:24
问题 Apparently Close and Dispose are effectively the same. I want to be able to Close and Open my ServiceHost instance without having to reinstantiate it everytime. Any ideas? Thanks. 回答1: ServiceHost.Close is effectively identical to Dispose() . This is true, in general, with all types that have a Close() method - Dispose() is implemented in terms of Close() . FYI - ServiceHostBase implements Dispose() explicitly via: void IDisposable.Dispose() { base.Close(); } This, effectively, means that

Can I call a method in a Self-Hosted WCF Service locally?

懵懂的女人 提交于 2019-12-04 18:27:58
问题 I have a WCF Service contract which is basically the Publish Subscriber pattern. The WCF Service is hosted inside the Windows Service that I want to publish from. The Clients subscribe to messages and when the Windows Service does something it publishes to all clients. To host the service I have declared a ServiceHost class and the Contract Class has a method which is not flagged in the Interface but is implemented in the Class to publish. I want to be able to call this method locally (not

Async WCF self hosted service

早过忘川 提交于 2019-12-03 13:01:22
问题 My objective is to implement an asynchronous self hosted WCF service which will run all requests in a single thread and make full use of the new C# 5 async features. My server will be a Console app, in which I will setup a SingleThreadSynchronizationContext , as specified here, create and open a ServiceHost and then run the SynchronizationContext , so all the WCF requests are handled in the same thread. The problem is that, though the server was able to successfully handle all requests in the

Can I call a method in a Self-Hosted WCF Service locally?

人盡茶涼 提交于 2019-12-03 12:02:16
I have a WCF Service contract which is basically the Publish Subscriber pattern. The WCF Service is hosted inside the Windows Service that I want to publish from. The Clients subscribe to messages and when the Windows Service does something it publishes to all clients. To host the service I have declared a ServiceHost class and the Contract Class has a method which is not flagged in the Interface but is implemented in the Class to publish. I want to be able to call this method locally (not going through WCF) which then publishes the message via Callbacks. I can't seem to get from ServiceHost

Async WCF self hosted service

我的梦境 提交于 2019-12-03 03:57:38
My objective is to implement an asynchronous self hosted WCF service which will run all requests in a single thread and make full use of the new C# 5 async features. My server will be a Console app, in which I will setup a SingleThreadSynchronizationContext , as specified here , create and open a ServiceHost and then run the SynchronizationContext , so all the WCF requests are handled in the same thread. The problem is that, though the server was able to successfully handle all requests in the same thread, async operations are blocking the execution and being serialized, instead of being

WCF:: ServiceHost: Oddity…Still alive even if thread is dead?

旧时模样 提交于 2019-12-01 21:10:32
a new member here. Nice to see such a neat community. After a bit of research, I decided to use WCF in my application to do inter process communication, so I am using the NetNamedPipeBinding binding. The ServiceHost hosting application is not a dedicated server, so it has to spawn the ServiceHost via a thread. So far so good. So I have something like the following: Foo() { Thread serverThread = new Thread(new ThreadStart(ServerThread)); serverThread.Start(); Console.WriteLine("Foo Exited"); } ServerThread() { Uri baseAddress = new Uri("net.pipe://localhost/service"); ServiceHost serviceHost =

Cross domain policy file over net.tcp for WCF servicehost and Silverlight 5

大城市里の小女人 提交于 2019-12-01 11:55:27
问题 I have a locally hosted WCF service and a silverlight 5 app that communicates with it. By default silverlight tries to obtain the cross domain policy file over HTTP when making calls to the WCF service. I need to change this so that the policy file is served over net.tcp port 943 instead. I have setup a local tcp listener that serves up the policy file over port 943 and i have followed this technique whereby i make a dummy socket connection in order to obtain the policy file over tcp as it is

WCF threading - non-responsive UI

旧街凉风 提交于 2019-11-30 13:36:13
问题 I'm trying to configure some WCF stuff. Currently, I have a server which allows remote users to download files, and client. In the server, I use a ServiceHost class. I assume it should be running on a separate thread, however, the server UI (WinForms) becomes locked when someone downloads a file. Is there a way to manage the WCF threading model? Thank you! 回答1: You should add a ServiceBehaviorAtttribute to the class implementing your service and set its UseSynchronizationContext property to