Take the 2-minute tour ×

I have a question about references to WCF Services. I have two apps:

Console app
----WCF Service

The console app and library are in the same solution. Because of the WCF service in the library, its app.config has info for the WCF Service.

The console app config has nothing about the WCF Service. The console app calls the WCF Service indirectly through the library. I'm guessing that is why the console app has no WCF info in its config (since it knows nothing about the web service). The console app does a call to a static method in the library, which handles the WCF call.

I'm getting this error on the above call:

Could not find default endpoint element that references contract 'MyServiceReference.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element

Does the host (console app) need the WCF Service related info from the library? If so, why didn't VS2010 add it.

share|improve this question
add comment

2 Answers

The library you created ("--Library", in your hierarchy) likely added a service reference to your WCF service. ("in the library" makes no sense, so I'm assuming that's what you meant). This means that a bunch of information about the WCF service was added to the app.config for the library. That information needs to be in the app.config of any exe that references the library in order for the library to correctly access the WCF Service that it references.

share|improve this answer
add comment

What I'd suggest is running the SVCUtil.exe. You can run it against the running service like this:

svcutil.exe http://localhost:Port/YourSvcClass/YourSvcMethod /language:c# 

What that will do is build a client-side c# (or vb) stub class in c#, plus a .Config file with the exact client side configuration file you'd need to connect ... all the good stuff. You can also run svcutil against your WCF dll like this:

svcutil.exe c:\yourfolder\YourService.dll /language:c#

Whether you use the stub class or not, the .config file will be helpful in setting up the client.

Good luck

share|improve this answer
add comment

Your Answer


