开发者

Discover WCF services in Solution

I have a solution with a WCF service which works fine. I have added a small console app in the solution which needs to have a Servi开发者_开发问答ce reference to the service in the same solution. It discovers the service but obviously can't connect to it as the service is not running. How in Visual Studio 2010 I can have the service running in the solution and at the same time add a service reference in the same solution?


Assuming the Client Application is in the same solution as the WCF Service project, r-click the client application and choose "Add Service Reference".

A dialogue is displayed allowing you to select your Service by clicking the button in the top right labelled "Discover".

Assuming the binding is correctly set and available for the WCF Service (via an app.config file or similar) the IDE will automatically host the service for you. - note, the app.config should be located within the WCF Service project unless there is a designated host already available in another project within the solution.

If there are any issues hosting the service, a new dialogue will appear, with the right hand column for your service endpoints saying "Error". Clicking the errored line will explain why there is an issue and hopefully help you to resolve it.


Not true. WCF Service projects can self host themselves within the IDE for the purpose of adding service references

Yes, if the project with service is the main project of the solution, but if we want to start a client app from the same solution we need to set main project to client app and as result wcf app won't start by itself, so we need helper class that hosts wcf.


If you are trying to build a console application that self-hosts the WCF project in the same solution, use "Add Reference" (instead of "Add Service Reference") and under Solution you will find the Service in your Solution.


Right-click on the project in the Solution Explorer, and select Unload project

Right-click the project again (this time the node will end in (unavailable) ) and choose Edit xxxxx.csproj

In the first section, add the following line: {3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

Save and close the file Reload the project by right-clicking it again and choose Reload. You should then be able to use the "Discover services in solution" functionality

Run the application and attach the debugger to wcfsvchost.exe


http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx

You need to host your service. Create a class that will do it in the same solution

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜