Related
I have a C# Asp.net web project made in Visual Studio.
The project runs on a certain port (57243) and I made other programs that were testing the web service etc to use "localhost:57243".
Recently I tried running the project in Jetbrains' Rider IDE because of whatever reasons I made up at the time.
The only issue I am having now is that the web service runs on port 5001 and I cannot find any property to change the base url or the host port to make it work.
TLDR, I am looking for this option inside the Jetbrains' Rider IDE:
This can be done inside the Rider IDE if you like.
If you edit the run/build configuration you are using when you hit F5 and then edit the environment variables you can add the ASPNETCORE_URLS environment variable which will run the app using the port specified as shown here.
Rider Run configuration environment variables
Steps to edit the setting
Open the edit screen for the run/build configuration
Click the ellipsis on the environment variables edit box to edit
Click the plus (+) symbol to add a new evironment variable
Set the name to ASPNETCORE_URLS and the value to http://*:57243
Save your changes and run
#Sasquatch's answer works for ASP.NET Core only.
For plain old ASP.NET, with IIS Express, we can go the project properties, Web section, and then
Make sure "Server type:" is "IIS Express".
Check "Generate applicationhost.config". [*]
Set "URL:" to "localhost".
Set "Development port:" to whichever port you want ("1234" in this example).
Click "OK" and restart the web application.
This will rewrite the generated applicationhost.config file (in .idea\config\ folder) with your selected configuration.
[*] If "Generate applicationhost.config" is unchecked, you should edit that file directly, like #WWietlol's answer suggests.
It turned out that the option in Visual Studio just changes the application.config in the .vs folder.
A similar file in the .idea folder had the properties of the ports.
Changing it in that file fixed it.
To set the Port on JetBrain Rider v2019.1, in the solution view, open the launchSettings.json file in the Solution > Project > Properties folder. You will be able to set the applicationUrl port for both the https://localhost:{port} and http://localhost:{port}.
Make sure you restart the that app, to use the new port.
Removing all files in the .idea folder helped me. Rider showed me the initial window of to configure my project from scratch and imported all necessary settings (like environment and url) automatically.
I was unable to configure a root as per rsennas answer with an ASP.NET MVC project.
Neither Rider nor Visual Studio control the configuration of the web server (IIS Express), instead they both just generate an applicationhost.config file that they pass to IIS Express. You should see something like this when you start the application from Rider
C:/Program Files/IIS Express/iisexpress.exe "/config:C:/foo/.idea/config/applicationhost.config" "/site:foo" /apppool:Clr4IntegratedAppPool
Starting IIS Express ...
to spot which applicationhost.config file is used. Specifically, the relevant section looks (ish) like this
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<!-- ... -->
</site>
Unfortunately, neither Rider nor Visual Studio is particularly good at generating this file. Rider tends to yield incorrect configurations and Visual Studio tends to be inconsistently formatted ¯\_(ツ)_/¯
You can use a diff-tool (like vimdiff) to compare the two (preferably after harmonizing the formatting) and pull the relevant configurations from one file to the other.
Specifically, it appears IIS Express requires a root website. In my case I had to change something like this
<site name="foo" id="1" serverAutoStart="true">
<application path="/foo">
<virtualDirectory path="/" physicalPath="C:/Foo" />
</application>
</site>
into
<site name="foo" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<application path="/foo">
<virtualDirectory path="/" physicalPath="C:/Foo" />
</application>
</site>
l am using Asp.Net Maker 2016 for generating my project. So, l browse my project via vs2015. The problem is after I generate my project from Asp.Net Maker tool and open it in vs2015, the URL of my project is changed.
something like :
http://localhost:51624/ADD
I want to set the port fixed not dynamic so, how I can do this in vs2015 or Asp.Net 2016 Maker tool?
Visual Studio uses IIS Express to run Web Projects. When a project is run first time IISExpress creates an entry to applicationhost.config file for the project and assigns a random port to it. The file is located at - %userprofile%\Documents\IISExpress\config folder.
Project entries in the file looks like this -
<site name="ProjectName" id="5">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="d:\physical path" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:59302:localhost" />
</bindings>
</site>
Notice the bindingInformation="*:59302:localhost" in the above section. Here the port number is 59302. You can change this port number to anything you like and next time Visual Studio runs the project it will use your assigned port number.
Its best to close all instances of VS and also confirm that IISExpress is not running before changing the file. Also, keep a backup of the file beforehand just in case.
The port you assign also needs to be free. i.e. no other application should be using the port. Else Visual Studio will fail to run the application.
I've encountered an error deploying a site to a server. When trying to load the home page, or access authentication on the new site in IIS, I get the error:
Config Error: This configuration section cannot be used at this path.
This happens when the section is locked at a parent level. Locking is
either by default (overrideModeDefault="Deny"), or set explicitly by a
location tag with overrideMode="Deny" or the legacy
allowOverride="false".
More detail can be found here, in Scenario 7 matches my hex error code.
The solution given on the linked site above is to set Allow for overrideModeDefault in the section mentioned in my error, in the applicationHost.config file. In my case, under Security in system.webServer. But if I look at the applicationHost.config on my local computer, where the site is properly deployed already, that section is set to Deny.
If this solution is correct, how is my local instance running just fine with the same web.config? According to my applicationHost.config, that section should be locked, but it's not. I'd prefer to not change the applicationHost.config file, because there are many other sites running on that server. Is there another solution?
I had the same problem. Don't remember where I found it on the web, but here is what I did:
Click "Start button"
in the search box, enter "Turn windows features on or off"
in the features window, Click: "Internet Information Services"
Click: "World Wide Web Services"
Click: "Application Development Features"
Check (enable) the features. I checked all but CGI.
btw, I'm using Windows 7. Many comments over the years have certified this works all the way up to Windows 10 and Server 2019, as well.
You could also use the IIS Manager to edit those settings.
Care of this Learn IIS article:
Using the Feature Delegation from the root of IIS:
You can then control each of machine-level read/write permissions, which will otherwise give you the overrideMode="Deny" errors.
For Windows Server 2012 and IIS 8, the procedure is similar.
The Web Server (IIS) and Application Server should be installed, and you should also have the optional Web Server (IIS) Support under Application Server.
Browse to “C:\Windows\System32\inetsrv\config” (you will need administrator rights here)
Open applicationHost.config
Note: In IISExpress and Visual Studio 2015 the applicationHost.config is stored in $(solutionDir).vs\config\applicationhost.config
Find the section that showed up in the “config source” part of the error message page. For me this has typically been “modules” or “handlers”
Change the overrideModeDefault attribute to be Allow
So the whole line now looks like:
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
After saving the file, the page loaded up fine in my browser.
Warning:
Editing applicationHost.config on 64-bit Windows
You need to unlock handlers. This can be done using following cmd command:
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers
Maybe another info for people that are getting this error on IIS 8, in my case was on Microsoft Server 2012 platform. I had spend couple of hours battling with other errors that bubbled up after executing appcmd. In the end I was able to fix it by removing Web Server Role and installing it again.
1. Open "Turn windows features on or off" by: WinKey+ R => "optionalfeatures" => OK
Enable those features under "Application Development Features"
Tested on Win 10 - But probably will work on other windows versions as well.
I ran these two commands from an elevated command prompt:
%windir%/system32/inetsrv/appcmd unlock config /section:anonymousAuthentication
%windir%/system32/inetsrv/appcmd unlock config /section:windowsAuthentication
As per my answer to this similar issue;
Try unlocking the relevant IIS configuration settings at server level, as follows:
Open IIS Manager
Select the server in the Connections pane
Open Configuration Editor in the main pane
In the Sections drop down, select the section to unlock, e.g. system.webServer > defaultPath
Click Unlock Attribute in the right pane
Repeat for any other settings which you need to unlock
Restart IIS (optional) - Select the server in the Conncetions pane, click Restart in the Actions pane
This Did the trick for me, for IIS 8 Windows server 2012 R2
Go to "Turn on Features"
Then go to all default setting , Next, Next, Next etc..
Then, select as shown below,
Then reset IIS (optional) but do it safer side.
This is an additional solution as its a generic problem everyone have different of problem and thus different solution. Cheers!
The best option is to Change Application Settings from the Custom Site Delegation
Open IIS and from the root select Feature Delegation and then select Application Settings and from the right sidebar select Read/Write
On Windows Server 2012 with IIS 8 I have solved this by enabling ASP.NET 4.5 feature:
and then following ken's answer.
To fix this open up the IIS Express applicationhost.config. This file is stored at C:\Users[your user name]\Documents\IISExpress\config\applicationhost.config
Update for VS2015+: config file location is $(solutionDir).vs\config\applicationhost.config
Look for the following lines
<section name="windowsAuthentication" overrideModeDefault="Deny" />
<section name="anonymousAuthentication" overrideModeDefault="Deny" />
<add name="WindowsAuthenticationModule" lockItem="true" />
<add name="AnonymousAuthenticationModule" lockItem="true" />
Change those lines to
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
Save it and refresh Asp.net Page.
In our case on IIS 8 we found the error was produced when attempting to view Authentication" for a site, when:
The server Feature Delegation marked as "Authentication - Windows" = "Read Only"
The site had a web.config that explicitly referenced windows authentication; e.g.,
Marking the site Feature Delegation "Authentication - Windows" = "Read/Write", the error went away. It appears that, with the feature marked "Read Only", the web.config is not allowed to reference it at all even to disable it, as this apparently constitutes a write.
Seems that with IIS Express and VS 2015, there's a copy of the applicationHost.config file at $(solutionDir).vs\config\applicationhost.config so you'll need to make changes there. See this link: http://digitaldrummerj.me/iis-express-windows-authentication/
Make sure these lines are changed per below:
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="WindowsAuthenticationModule" lockItem="false" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
In my case it was that on server was not enabled "HTTP Activation" under .NET Framework Features. So for Windows Server 2012 the solution which worked for me was:
Server Manager -> Add roles and features -> Features -> make sure that under .NET Framework of version you want to use is checked "HTTP Activation"
The Powershell way of enabling the features (Windows Server 2012 +) - trim as needed:
Install-WindowsFeature NET-Framework-Core
Install-WindowsFeature Web-Server -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-Features -IncludeAllSubFeature
Install-WindowsFeature NET-Framework-45-ASPNET -IncludeAllSubFeature
Install-WindowsFeature Application-Server -IncludeAllSubFeature
Install-WindowsFeature MSMQ -IncludeAllSubFeature
Install-WindowsFeature WAS -IncludeAllSubFeature
The error says that the configuration section is locked at the parent level.
So it will not be directly 1 config file which will resolve the issue,
we need to go through the hierarchy of the config files to see the inheritance
Check the below link to go through the File hierarchy and inheritance in IIS
https://msdn.microsoft.com/en-us/library/ms178685.aspx
So you need to check for the app config settings in the below order
ApplicationHost.config in C:windows\system32\inetsrv\config. Change the overrideModeDefault attribute to be Allow.
ApplicationName.config or web.config in the applications directory
Web.config in the root directory.
Web.config in the specific website (My issue was found at this place).
Web.config of the root web (server's configuration)
machine.config of the machine (Root's web.config and machine.config can be found at - systemroot\MicrosoftNET\Framework\versionNumber\CONFIG\Machine.config)
Go carefully through all these configs in the order of 1 to 6 and you should find it.
I noticed one answer that was similar, but in my case I used the IIS Configured Editor to find the section I wanted to "unlock".
Then I copied the path and used it in my automation to unlock it prior to changing the sections I wanted to edit.
. "$($env:windir)\system32\inetsrv\appcmd" unlock config -section:system.webServer/security/authentication/windowsAuthentication
. "$($env:windir)\system32\inetsrv\appcmd" unlock config -section:system.webServer/security/authentication/anonymousAuthentication
I needed to change the SSL settings on a subfolder when i got this nice message. In my case following action helped me out.
Opened C:\Windows\System32\inetsrv\config\applicationHost.config
And changed the value from overrideModeDefault="Deny" to "Allow"
<sectionGroup name="system.webServer">
...
<sectionGroup name="security">
<section name="access" overrideModeDefault="Allow" />
</sectionGroup>
In my case, I got this error because I was operating on the wrong configuration file.
I was doing this:
Configuration config = serverManager.GetWebConfiguration(websiteName);
ConfigurationSection serverRuntimeSection = config.GetSection("system.webServer/serverRuntime");
serverRuntimeSection["alternateHostName"] = hostname;
instead of the correct code:
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection serverRuntimeSection = configApp.GetSection("system.webServer/serverRuntime", websiteName);
serverRuntimeSection["alternateHostName"] = hostname;
in other words, I was trying to operate on the website's web.config instead of the global file C:\Windows\System32\inetsrv\config\applicationHost.config, which has a section (or can have a section) for the website. The setting I was trying to change exists only in the applicationHost.config file.
In my case, it was something else.
When I loaded the solution in a new version of Visual Studio, VS apparently created a new project-specific applicationhost.config file:
MySolutionDir\.vs\config\applicationhost.config
It started using the settings from the new config, instead of my already customized global IIS Express settings.
(\Users\%USER%\Documents\IISExpress\config\applicationhost.config)
In my case this was the setting that needed to be set. Of course it could be something else for you:
<section name="ipSecurity" overrideModeDefault="Allow" />
Received this same issue after installing IIS 7 on Vista Home Premium. To correct error I changed the following values located in the applicationHost.config file located in Windows\system32\inetsrv.
Change all of the following values located in section -->
<div mce_keep="true"><section name="handlers" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"</div>
<div mce_keep="true"><section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"</div>
Can You try this:
Go to application path where you're getting deny error, right click
Properties->Security tab
In that, change the permissions and check the checkbox read and write. Then it will work without any error hopefully.
For Windows Server 2008 and IIS 7, the procedure is similar.
please refer to this:
http://msdn.microsoft.com/en-us/library/vstudio/bb763178(v=vs.100).aspx
in add role service, u will see "Application Development Features"
Check (enable) the features. I checked all.
In my case I was getting this error when attempting to update the authentication settings in IIS also in addition to browsing. I was able to remove this error by removing the authentication setting from the web.config itself. Removing a problematic configuration section may be less invasive and preferable in some cases than changing the server roles and features too much:
Section Removed:
<security>
<authentication>
<windowsAuthentication enabled="true" />
</authentication>
</security>
I had the similar issue, but I used the following powershell script which helped me to achieve above steps in on button click.
#Install IIS
Import-Module ServerManager
Add-WindowsFeature Web-Server, Web-Asp-Net45, Web-Mgmt-Console, Web-Scripting-Tools, NET-WCF-HTTP-Activation45, Web-Windows-Auth
the list of features can be added or removed based on the requirement.
I had an issue where I was putting in the override = "Allow" values (mentioned here already)......but on a x64 bit system.......my 32 notepad++ was phantom saving them. Switching to Notepad (which is a 64bit application on a x64 bit O/S) allowed me to save the settings.
See :
http://dpotter.net/technical/2009/11/editing-applicationhostconfig-on-64-bit-windows/
The relevant text:
One of the problems I’m running down required that I view and possibly edit applicationHost.config. This file is located at %SystemRoot%\System32\inetsrv\config. Seems simple enough. I was able to find it from the command line easily, but when I went to load it in my favorite editor (Notepad++) I got a file not found error. Turns out that the System32 folder is redirected for 32-bit applications to SysWOW64. There appears to be no way to view the System32 folder using a 32-bit app. Go figure.
Fortunately, 64-bit versions of Windows ship with a 64-bit version of Notepad. As much as I dislike it, at least it works.
I had the same issue.
Resolved it by enabling Application Server feature. Restarted iis
after that.
This worked for me
Also in IIS 8 you can solve this problem by changing the server to IIS Express. Goto debug->Properties
In the Web select the server as IIS Express from the dropdown and then rebuild the solution
To make a change at Application Level (Web.Config):
Please remove the Trust Level from the web.config:
Actually I was getting this error when I was trying to host my Website on the Hosting Server where I don't have control on their Server. Removing the above line from my Application web.config solved my issue.
I want to test some subdomain features in an asp.net site. I read just to edit the hosts file and add 127.0.0.1 subdomain.domain.com and that should work.
But mine seems to not. I have flushed the dns, restarted, tried new browsers and still get error 500.
When I normal run the asp.net site from Visual Studio it goes to http://localhost:17365/ . How do I get the IP address for this?
I guess I don't get the whole picture and missing some pieces.
I ran netstat -n and see that the site is running on[::1]:17365 maybe thats why its not working under ipv4?
The solution is very simple.
After you have edit your host files adding a line as:
127.0.0.1 subdomain.domain.com
you run your site, the personal web starts and you get on your browser this
http://localhost:[PortNumber]/ (eg: http://localhost:17365/ )
just change it to
http://subdomain.domain.com:[PortNumber]/ (eg:http://subdomain.domain.com:17365/)
with your hand, type it on the url on your browser, and it will work.
In visual studio when you go to run the site first change in the Website Properties > Use Dynamic PortstoFalse, then set the Port Numberto80, then run it.
It will by default launch http://localhost:80, however then in your browser visit subdomain.domain.com in your browser it will point to your debugging instance of your site (assuming you've still got that 127.0.0.1 subdomain.domain.com in your hosts file).
I just go to Project Properties > Web and under Servers, I select Use Local IIS Web server and set the Project Url to subdomain.domain.com.
Someone has registered "lvh.me" that point to 127.0.0.1
So you can use:
http://lvh.me
http://something.lvh.me
You have to configure your web server also.
Ok, you changed the hosts file. Your system (dns) knows where to go (127.0.0.1) with the host.
But your web server still know nothing about subdomain.domain.com and associates nothing with it.
When you normally start an asp.net site in Visual Studio it uses the Cassini webserver.
I'm not sure if you can configure bindings for Cassini.
My suggestion would be to configure a website or virtual directory in IIS with bindings to subdomain.domain.com, look here on how to do that: Add a binding to a site
Your hosts file should contain this:
127.0.0.1 subdomain.domain.com
The request of subdomain.domain.com will then be redirected to your Local IIS Web server (on port 80), because of the binding configuration IIS knows where to look for your website.
Within the properties of your web project in Visual Studio you can configure to use Local IIS Web server in the Web tab.
I'm not sure that the Visual Studio Development Server can handle bindings to anything other than localhost. I think the only thing you can change is the port number.
You have a couple of options.
1) Install IIS Express (or full-on IIS if you want) and configure Visual Studio to point to the site you have set up in there. You can manually set up your binding to subdomain.domain.com and it's very flexible. Take a look at this answer: Using Custom Domains With IIS Express
2) Install a port forwarder like rinetd (I think this should work if you have the entry in your hosts file). You should be able to map subdomain.domain.com:<some port number> to localhost:17365. Note that rinetd won't detect the domain you're using (just the underlying IP address which is 127.0.0.1), so it's best to use a distinct port for each project you're working on.
Goto applicationhost.config, you can find on windows tray.
Finding application.config of a current running project in IIS
Now find
<webLimits>
......
<sites>
.....
<site name="[YourProjectName]" id="[YourProjectID]">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="[Your Project Path]" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:50569:[Remove localhost from here]" />
</bindings>
</site>
.....
</sites>
......
<webLimits />
Remove localhost from bindingInformation.
Finally, Run VisualStudio as Administrator
I'm using VS 2017 and Webforms (don't say it).
In the Solution (.sln) file (in notepad) I changed the port to 8080. This was found in several properties, including VWDPort, Debug.AspNetCompiler.VirtualPath, Debug.AspNetCompiler.TargetPath, Release.AspNetCompiler.VirtualPath, and Release.AspNetCompiler.TargetPath
In the applicationhost.config file, I added:
<binding protocol="http" bindingInformation="*:8080:subdomain.domain" />
Also done in notepad. Make sure there are no duplicate or old entries anywhere in this file for bindings. After you change the port in Step 1 you may get an auto-generated duplicate entry with old bindings. Also, be sure you editing the correct applicationhost.config file. This file is in a different place depending on your version of VS.
In Powershell, run: "netsh http add urlacl url=http://subdomain.domain:80/ user=everyone"
In your hosts file (mine is in C:\Windows\System32\drivers\etc) add "127.0.0.1 subdomain.domain" to your hosts listing. You'll have to be an administrator (right-click on notepad, run as administrator)
Run VS as Administrator. This will keep the port to 80. If not run as administrator, you'll get a random port number, your .sln file will get auto-edited with this number, and you'll get duplicate bindings in applicationhost.config.
Running as Administrator is irritating, but it's the only way I could get the port to not change. Also, I tried using other ports, such as the one randomly assigned VS, but kept running into 503 errors from IIS.
Using this you could get a list of IP addresses if I add this code it resolves to
127.0.0.1 please confirm if this is what you are looking for otherwise I will remove the answer
foreach (IPAddress address in Dns.GetHostAddresses("localhost"))
{
Console.WriteLine(address.ToString());
}
I've got a Visual Studio 2008 solution with a WCF service, and a client.
When I run my client, and call a method from my service I get a message saying "Unable to automatically debug 'Home.Service'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the server."
I've googled around, and have tried the following.
<system.web>
<compilation debug="true" />
</system.web>
has been added in app.config on both the client and the server.
I have also made sure that the project is being compiled in Debug mode.
What else could be causing this message?
Edit: Added more info based on feedback questions
It is using wsHttpBinding
I have set
<serviceDebug includeExceptionDetailInFaults="true"/>
I am using
var service = new HomeReference.HomeServiceClient();
service.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
Unfortunately the error shows up the first time I call a method on my Service. I can dismiss the messagebox, and the application continues working. Any Exceptions thrown on the server at not propagated back to the client though (I assume it should?)
I was fighting with this exact same error for over an hour and low and behold I restarted VS2008 and it magically fixed itself. Give it a try as it might save you some time.
In my case the problem turned out to be a mismatch between security settings on client and server. I was using a custom binding like this:
<customBinding>
<binding name="AuthorisedBinaryHttpsBinding" receiveTimeout="00:03:00" sendTimeout="00:03:00">
<!-- this next element caused the problem: -->
<security authenticationMode="UserNameOverTransport">
</security>
<binaryMessageEncoding>
<readerQuotas maxDepth="100" maxStringContentLength="1000000"
maxArrayLength="655360000" />
</binaryMessageEncoding>
<httpsTransport />
</binding>
</customBinding>
When I removed the security element that I've highlighted above the problem with the "Unable to automatically debug" message went away.
To solve the problem I first turned on WCF tracing. This showed me that WCF was throwing a MessageSecurityException:
Security processor was unable to find
a security header in the message. This
might be because the message is an
unsecured fault or because there is a
binding mismatch between the
communicating parties. This can
occur if the service is configured for
security and the client is not using
security.
That pointed me to look at the Binding settings on the client side. It turned out that I hadn't added the required security element to my custom binding there. Since I was doing this through code, I needed the following (note the 3rd line):
var binding = new CustomBinding(
binaryEncoding,
SecurityBindingElement.CreateUserNameOverTransportBindingElement(),
new HttpsTransportBindingElement { MaxReceivedMessageSize = MaxMessageSize, });
As to why Visual Studio was showing that error, I've no idea - looks to me to be a bug.
Automatically attaching to a service has the following limitations:
The service must be part of the Visual Studio solution you are debugging.
The service must be hosted. It may be part of a Web Site Project (File System and HTTP), Web Application Project (File System and HTTP), or WCF Service Library project. WCF Service Library projects can be either Service Libraries or Workflow Service Libraries.
The service must be invoked from a WCF client.
Debugging must be enabled with the following code in the app.config or Web.config file:
<system.web>
<compilation debug="true" />
</system.web>
See Limitations on WCF Debugging
In addition, if both projects (client and service) are in the same solution but will run in different processes (for example if you are using your local IIS Server for development and are running your web application on a different application pool than the service it consumes), you may need to enable "Multiple startup projects" for the solution (on Solution Properties -> Startup Project) so that the debugger can attach to both.
To avoid the service browser window to show up every time you debug, you may set the "Start Action" (on service project properties) to "Don't open a page. Wait for request from external application."
This is from personal experience and may help others.
The other reason you might see this error (and I believe is the case for me) is if you're running in 64bit Windows. Apparently Visual Studio doesn't have any x64 debugger support.
You can work around this by changing the Platform Target for the consuming application:
Project Properties -> Build -> Change "Platform Target" to "x86".
Unfortunately this won't work for me as I'm trying to run in the Windows Azure Development AppFabric which seems to require everything to run in 64bit mode!
I also got the same problem. I changed in both client & service config files like
Compilation debug is set to true.
This worked for me.
Have you tried
<serviceBehaviors>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
For debugging purposes?
Edit : nevermind, I think I misunderstood the question
I've had a similar problem and it turns out to have been due to Windows Authentication not being enabled on the IIS site/virtual directory.
Have you tried setting the authentication mode to Integrated instead of Anonymous?
http://msdn.microsoft.com/en-us/library/x8a5axew(VS.80).aspx
In your web service web.config ensure that compilation debug is set to true.
That should fix your problem!
In my case the problem turned out to be something completely different. I had changed the name of an operation on the webservice and forgot to update the client. For some reason this resulted in the "Unable to automatically debug ..." error.
It can also be that the same port number is used in IISExpress and IIS. If you are developing a WCF application in Visual Studio and IISExpress and then install the same application on your local IIS make sure not to use the same port number in IIS and IISExpress. Using the same port number will lead to this error message.
I had the same issue in Visual Studio 2017. After deleting the hidden .vs folder in the root of the solution folder, I was able to debug again.
Add this line of code after you create your service reference in your client.
MyWCFService.IService _proxy = new MyWCFService.IService();
_proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;