views:

302

answers:

1

When creating a new service in a WCF service project, Visual Studio will automatically put configuration information into the service's web.config file. Is there anyway to replicate this behavior with a new web config file and an existing service class in a service project? Sometimes the service's web.config seems to get mangled up either through user error or visual studio quirks. It would be nice to delete the service's web.config and get a fresh one that is auto configured using the same default configuration as if a new service class were created in VS.

Is there anyway to accomplish this?

EDIT: I'm referring to the service's web.config file not the client web.config/app.config.

A: 

Sure - you can run the command-line utility svcutil.exe against your service (directly using the URL or the WSDL as a file). This will by default generate a output.config config file which contains all the necessary settings in the <system.serviceModel> section. Just copy & paste into your new or existing web.config.

Marc

EDIT: From comments below, the answer is no in the case of the server side config.

marc_s
This doesn't seem to be working. I created solution with service1.svc. Deleted the web config. Added new web.config (now it has no service config), then I called svcutil.exe http://localhost:18799/service1.svc. It throws an exception because there are not endpoints configured.
Daniel Auger
OK - you want to create the SERVER side of things...... I don't think there's any "magic" way to do this - you'll just need to create the service config manually, I'm afraid.
marc_s
Sorry for the confusion. Thanks for the reply. It is as I feared ;).
Daniel Auger