简体   繁体   中英

Self-hosting a WCF service

I'm using a WCF service and i'm hosting it in a console application. I have all of my configuration in an XML file. The service works well and i can connect it it fine from the client, but what bothers me is that when i start it the WcfSvcHost app starts (in my icon tray) and says "Your service(s) have been hosted....". But when i click on it it shows my service and under status it says Stopped (with the error that there are no endpoints defined).

I have two projects, one with the service and another one that hosts it. The error points to the project that has the service in it, which has no configuration defined since ( i assume ) it is not needed there. I have all of my configuration in the project that hosts the service, inside App.config.

How do i get rid of the message? And is it even a problem or is it normal?

PS I only start the project that hosts the service, not the one that has the service code.

After some clicking around the project i've found the solution. If you right click on the Service Library project, under WCF Options, there is an option "Start WCF Service Host when debugging another project in the solution" just uncheck that and it will stop.

Also, check Scott Chamberlain's answer, that might be the cause in some cases.

If WcfSvcHost is starting then your hosting app is not starting. Even though you say you are starting the hosting app double check if you have the service library is set as a start-up project.

在此处输入图片说明

In the above image, Startup Project should be HostingApp you likely have it set to WcfServiceLibrary


One other possibility is your Hosting app is set up wrong, in the project settings for the hosting app, check that the output type is Windows Application .

在此处输入图片说明

If you had it set to Class Library then in your "Command line arguments" you have /client:"WcfTestClient.exe" that would also cause your issue. This can easily happen if you started the project as a "Serivice Library" but then later decided to turn it in to the hosting app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM