Visual Studio does not generate app.config content when "add service reference"
Asked Answered
N

5

33

When I add a web service by using "add service reference" in the console app, the app.config does not generate the configuration. How do I generate this app.config with a specific wsdl? Thanks!

Neil answered 29/1, 2010 at 0:31 Comment(4)
What version of Visual Studio are you using? I just tried it myself in an empty Console application, and it generated the app.config properly.Bascomb
This is occurring for me too using VS2010, against WCF Services generated by VS2010. More interested in finding a resolution for this than a work-around.Sickener
Added a bounty of 150 rep for an answer that resolves it without resorting to the command line.Sickener
This happened to me in VS 2013, Clara Onagers solution worked.Spirelet
F
20

When adding the service reference try clicking on the 'Advanced...' button and then uncheck the 'Reuse types in referenced assemblies' checkbox.

I found this out when I had created a simple project to test a third party service which all worked fine. Attempting to add the same reference to the main project resulted in the app.config and reference.vb file not being generated correctly.

I think this may have been because there were already other web references in the application or referenced applications, however unchecking 'Reuse types' resulted in the files being generated correctly.

Fagan answered 20/8, 2012 at 8:20 Comment(1)
Thanks! Was looking for a solution for a while now but your answer solved my problem :-)Demonography
H
9

(Same answer I gave at Visual Studio 2010: adding a service reference to a 2008 generated wsdl )


I have experienced the same issue with Visual Studio 2008. I find I get different results if I'm using the "Add Service Reference..." command, or digging deeper to "Add Service Reference..." | "Advanced..." | "Add Web Reference...".

However, the tried-and-true method--and the solution that worked for me--is still via the command line:

svcutil.exe /language:cs /out:GeneratedProxy.cs /config:app.config http://server/path_to/WebServiceBean?WSDL

That should give you a working app.config. Hope that helps!

Harryharsh answered 24/6, 2010 at 20:52 Comment(0)
N
2

In my case, following actions resolved

  1. Commented <services> tag in web.config file in WCF Project (from <services> to </services>
  2. Recompiled WCF project
  3. Hosted it at IIS
  4. At client application delete old reference and add again WCF reference

and it worked :)

Neille answered 19/9, 2016 at 7:36 Comment(0)
C
0

You can add a Service Reference as usual (no need for advanced). If the config sections do not appear in app.config, you can click "Configure Service Reference...", and uncheck "Reuse types in referenced assemblies". After that it will correctly generate the sections.

Cundiff answered 23/7, 2013 at 13:26 Comment(0)
M
0

This will not automatically generate your settings, but to create the web.config settings without the command line, you can right click on your app.config after adding the service reference and click the "Edit WCF Configuration" button to add the elements you need for your web service.

Maestro answered 13/2, 2014 at 13:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.