简体   繁体   中英

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 Service 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.

如果您正在尝试构建一个在同一解决方案中自行承载WCF项目的控制台应用程序,请使用“添加引用”(而不是“添加服务引用”),在解决方案下,您将在解决方案中找到该服务。

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

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