Visual Studio does not generate app.config content when "add service reference" - visual-studio

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!

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.

(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!

In my case, following actions resolved
Commented <services> tag in web.config file in WCF Project (from <services> to </services>
Recompiled WCF project
Hosted it at IIS
At client application delete old reference and add again WCF reference
and it worked :)

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.

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.

Related

Visual Studio Configuraiton manager Deploy column disabled

I am having a problem with the configuration manager in Visual Studio 2013. The Deploy column is disabled no. The only thing I did was a Repair of Visual Studio 2013 and not my WebAPI project not longer has the Deploy option enabled in Configuration Manager. I used to be able to do a file system deploy to the folder on the Web Server that hosted my WebAPI process. I am not sure what is going on. Any assistance would be greatly appreciated.
FYI - The CGSAPI project type is class library but that is what it has always been.
OK so I was just being silly. I have to right mouse button click on the actual WebAPI project and Publish will be available in the dropdown list. :)

visual studio 2015 "Add service reference" missing

I need to import a WSDL and I do not see "Add service reference" on menu when I right click project.
To add a reference to a service in the current solution
In Solution Explorer, right-click the name of the project that you
want to add the service to, and then click Add Service Reference.
The Add Service Reference dialog box appears.
Click Discover.
All WCF services in the current solution are added to the Service
list.
In the Service list, expand the node for the service that you want to
use and select a service contract.
In the Namespace box, enter the namespace that you want to use for the
reference.
Click OK to add the reference to the project.
A service client (proxy) is generated, and metadata describing the
service is added to the app.config file.
More information.

Stop Visual Studio 2013 modifying the IISExpress applicationHost.config

I have a website project using Visual Studio 2013, and each time I open it, it keeps adding a new entry for the website project in applicationHost.config. I use IISExpress for my development, however I always create a custom entry to provide some specifics and I have it configured to use port 80, so I would like to not have Visual Studio make any modifications to this file.
I have gone into Tools > Options > Web Projects and unchecked "Use the 64 bit version of IIS Express for web sites and projects", closed the solution, removed the entry from applicationHost.config and re-opened the project in Visual Studio, however it still continues to add an entry to applicationHost.config and name my website project whatever that entry is named.
Is there a way to disconnect Visual Studio entirely from IISExpress? I like using it, but I want to control that service and configuration myself.
Inside the bindings section of the site section, create a new binding in addition to the localhost version like so:
<bindings>
<binding protocol="http" bindingInformation="*:21232:localhost" />
<binding protocol="http" bindingInformation="*:21232:*" />
</bindings>
After having both lines, VS stopped making new site sections.
How to: Specify a Port for the Development Server
I just tried out the method described in the above msdn article to change the port IIS express uses (didn't try 80 though).
right click the website in solution explorer, remove (won't delete files)
edit the applicationHost.config file, change the binding
"add existing web site" in Visual Studio (point to the folder of site you previously removed)
At that point it doesn't seem to create a new entry in applicationHost.config, and uses the new port.
We have the same problem here. Two days googling for a solution without success. The only solution until now is to add the website to the solution using the Local IIS option.
I ran into this trouble when I was switching from one TFS workspace to another while experimenting with VS2013. I'd updated to VS2013 from VS2012 in a new workspace, then when I was done and committed the changes, I got the latest in my original workspace and began to use it there with VS2013. Every time I loaded my web project I got the message about it editing my project file, and every time it did, it screwed up the settings.
Here's how I fixed it, after trying the other answers here. A bad .csproj.user file was the problem. I do not use this file, generally, as I have the "Apply server settings to all users (store in project file)" checkbox in the Web properties checked. But I'd used it in the past. Deleting this file, or updating it so that the settings match those I've set in the project file (i.e. setting the port, whether to use IISExpress, etc.) fixed it. I can now load my project without visual studio making (the wrong) edits to my project file every time I load.
In the project properties, I see a "Web" tab, which contains a "Servers" section that has a dropdown where you can select from the following:
IIS Express
Local IIS
External Host
I believe selecting "Local IIS" is the option you need.
If you don't want to use a local development server, you can attach to an IIS process on a local machine very easily.
There's a way to set the build output location for debug in the properties (right-click project in solution explorer and choose 'properties). If you want to do this easily the first time with no extra setup, just copy your debug build's output to your website folder that you configured in IIS.
Next, ensure you can hit the IIS site. If so, go back to Visual Studio and go to the Debug-> Attach to Process menu item. Choose 'w3wp.exe' out of the list (you may have to check 'view all processes'). You should now be able to hit breakpoints in VS.
However, you should also be able to use IIS Express with a specific port, as #Anssssss said.

Why does Visual Studio automatically reenable "client application services"?

I have a solution consisting of a number of class library project, and a windows service project. When I open the project settings for the windows service project and (accidentally) click on the "Services" tab, Visual Studio insists on automatically ticking the "Enable client application services" checkbox.
The effect of this is that it will add a reference to System.Web.Extensions, and also insert some parts in the app.config. Disabling the checkbox again will not remove the reference. It will however remove the generated configuration, though it will also remove some unrelated configuration that were there before.
Why does it insist on ticking this checkbox, and can I make it not do it? The HELP documentation for the "Settings" tab does not mention any "auto-select" behaviour.
This is Visual Studio 2010, targeting .Net 3.5.
At least one other person have the same issue, unfortunately without any resolution provided:
http://go4answers.webhost4life.com/Example/visual-studio-2010-keeps-enabling-7689.aspx
That in turn links to a Microsoft Connect issue, but for some reason they don't allow access to older reports it seems: https://connect.microsoft.com/VisualStudio/feedback/details/570166
When there is AppSettings item in app.config, the setting “Enable client application services” will be always automatically checked on when to open the project property page.
Reproduce steps:
Using VSTS 2012
Create an empty console application
Add AppSettings section to app.config
Open the project property page and click the "Services" tab
You will see “Enable client application services” is checked on and app.config is updated.
One workaround from our team member:
just to rename the app.config to the its finally deployed file name, such as ConsoleApplication.exe.config and change its file property - "Copy to OutputDirectory" as "Copy if newer".
It works for our project.

"Unable to connect to the ASP.NET Development Server" message in Visual Studio 2010

I just checked out an ASP.NET MVC 3 web project using TortoiseSVN. I opened it in vs2010 and successfully built it. But when I try to run the project, vs2010 gives me an error with the following message "Unable to connect to the ASP.NET Development Server". When I open the development server dialog via icon in notification area and try to browse through the link in this dialog a web page opens with "HTTP Error 403 - Forbidden".
This looks quite odd, as when I create a new MVC project in the same solution and try to run it, it runs normally. This problem occurs only with the aforementioned project.
Please share any ideas.
This worked for me:
Open web.config
Remove everything in the <system.web> section
Run the project (it should work now)
Undo your web.config changes and you should be good to go.
Try to change assigned port in project properties-> Web-> set specific port instead of auto assign.

Resources