简体   繁体   中英

How to add a design time service reference to a console application in VS 2010?

I'm trying to create a simple WCF application. My service interfaces and implementations are in class libraries. I have written a very simple console application that acts as a server host.

Now I have created a silverlight client, and I'm trying to add a service reference, using the App.config in the console application, but the configured services are not showing up in the Discover->Services In Solution.

They do show up if I create a WCF class library to contain my services, but not a normal class library with an app.config.

I can run the console application and add the service reference then, but that seems a bit clumsy.

What are the rules for adding design-time service references?

Edit

Visibility of a project to design-time discovery appears to be controlled by the following project types:

{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

(adding these to a csproj requires that it contains at least one service).

Another rule appears to be that the service types have to be in the same assembly as the app.config that references them.

I believe Visual Studio uses different project types in your solution (metadata stored either in the solution-/project file or both) to identify potential candidates. If you create a console application Visual Studio won't treat it as if it could contain service reference, though as I think you've already figured out, changing the target type after the project has been created doesn't seem to have this effect because it doesn't invalidate that metadata.

Create two new projects, one of each and compare the two files with a diff tool or just notepad. See if copy the change between the projects and reloading (or even restarting VS) changes this behavior.

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