I am trying to host my WCF service in IIS 7.5, but everytime i run the website i get a page stating
Service Unavailable
HTTP Error 503. The service is unavailable.
I noticed that whenever I started the website the ASP.net v4.0 stopped automatically. I checked the eventviewer and this seems to be the error
The worker process for application pool 'ASP.NET v4.0' encountered an error 'Configuration file is not well-formed XML
' trying to read configuration data from file '\?\C:\Windows\Microsoft.NET\Framework64\v4.0.30319\CONFIG\web.config', line number '0'. The data field contains the error code.
I tried searching for solutions around the internet but none of them have been helpful so far.
I tried changing the identity of ASP.net v4.0 in IIS to LocalSystem and it didn't work
After that i tried setting up a "Custom account" by setting the username as my computer username and adding passwords but i got "The specified password is invalid, type a new password" even though i don't have any passwords for my account
3.The final thing i tried was to add IIS_IUSRS and IUSR to the security of the Web.config but still it didn't work
This is my Web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="mexBehavior"
name="HelloService1.HelloService1">
<endpoint address="HelloService1" binding="basicHttpBinding"
contract="HelloService1.IHelloService1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Try a re-install of the .NET Framework 4.0. Go to this location
%windir%\Microsoft.NET\Framework64\v4.0.30319
Run this command
aspnet_regiis -i
Related
None of the members of my team has ever been able to get a particular WCF service in our solution to work on our local machines. We've inherited it in legacy code and are trying to replace it, but it's very difficult to tell what it's doing since we can't run the debugger on it and we can't even get a response from it while debugging the main site that uses it.
The main part of our application is a web site. This particular service is hosted in a separate application pool on IIS due to some problems with using Excel interops (which this service uses) in the same app pool as the main site.
The service appears to use net.tcp for the protocol, and I have enabled the Windows Communication Foundation Non-HTTP Activation feature on my machine. I have also enabled the protocol on the Default Website and the node underneath it which is the WCF service in question (is this redundant?).
I can attach the debugger to w3wp.exe processes for both the site and the service. When the site makes the call to the service, however, an error is immediately returned and no breakpoints in the service are hit. The error reads:
The service 'MySvc.svc' cannot be activated due to an exception during
compilation. The exception message is: The type 'MyNamespace.MySvc',
provided as the Service attribute value in the ServiceHost directive,
or provided in the configuration element
Note, I have obviously redacted the real service name, etc, from this post. After attempting to follow solutions proposed on numerous similar questions, I have gotten nowhere. I am wondering if the problem is exacerbated by the separate app pools.
Below is the Web.config from the service project. The SVC file is named UploadAndImport.svc.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<!-- REDACTED SECTIONS PERTAINING TO LOGGING AND ENTERPRISE LIBRARY -->
</configSections>
<!-- REDACTED SECTIONS PERTAINING TO LOGGING AND ENTERPRISE LIBRARY -->
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.6.1" />
<identity impersonate="true" />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="ProjectName.UploadAndImport">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="" name="ExcelServiceEndPointHTTP" contract="ProjectName.IUploadAndImport" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint binding="netTcpBinding" bindingConfiguration="" name="ExcelServiceEndPointTCP" contract="ProjectName.IUploadAndImport" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!-- This line ignores the error that 'An ASP.NET setting has been detected that does not apply in Integratd managed pipeline mode (system.web/identity#impersonate is set to true)'-->
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
</configuration>
The directive in the SVC file looks like this:
<%# ServiceHost Language="VB" Debug="true" Service="ProjectName.UploadAndImport" CodeBehind="UploadAndImport.svc.vb" %>
I have problem reaching my WCF service on localhost. When I start it from Visual Studio, everything is fine. However, as soon as I stop debugging it, the service is no longer available. This is odd, because it happens only with projects created by myself. When I download a solution (e.g. this one), everything is just fine and the service is available also after I stop debugging it.
Thus, I suppose, it is a configuration problem. However, I am not able to find it. Here is my Web.config file:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name ="svcbh">
<serviceMetadata httpGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name ="DuplexServer.CalculatorService" behaviorConfiguration ="svcbh" >
<host>
<baseAddresses>
<add baseAddress = "http//localhost:3435/CalculatorService/" />
</baseAddresses>
</host>
<endpoint name ="duplexendpoint"
address =""
binding ="wsDualHttpBinding"
contract ="DuplexServer.ICalculatorDuplex"/>
<endpoint name ="MetaDataTcpEndpoint"
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
It sounds like the settings for your solution/project is not what you desire. Go the properties of your WCF project and look at "Web" settings(plenty of information on the net about this)
You will probably need to change from "Use Visual Studio Development Server" to "Use local IIS Web Server"
Assuming you are using IIS Express, it's usually caused by Edit and Continue (Right click the project, select properties. It's a checkbox in the Web tab).
Disable this, and the service should keep running when you stop debugging.
On a related note, if you wish to simply start the service to have available (i.e. you don't want to debug, you just want it running), you can use "Start without Debugging" in the Debug menu (CTRL + F5 by default)
This is my first WCF service and I am having what seems to be a common problem for newbies i.e. the configuration file.
The service project was created with examples from here and here and after receiving the error [Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.], I went through the MSDN way of Web.config here and here.
Here is my Web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Parkalot.WcfClient.Services.UserService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:7349/ServiceMetadata" />
</baseAddresses>
</host>
<endpoint address="/UserService" binding="wsHttpBinding" contract="Parkalot.WcfClient.Services.IUserServiceContract" />
<!-- Adds a WS-MetadataExchange endpoint at "http://localhost:7349/ServiceMetadata/mex" -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<!-- Enables the IMetadataExchange endpoint in services that -->
<!-- use "metadataSupport" in their behaviorConfiguration attribute. -->
<!-- In addition, the httpGetEnabled and httpGetUrl attributes publish -->
<!-- Service metadata for retrieval by HTTP/GET at the address -->
<!-- "http://localhost:8080/ServiceMetadata?wsdl" -->
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:7349/ServiceMetadata?wsdl" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The error details are:
Error: Cannot obtain Metadata from http://localhost:7349/Services/UserService.svc
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.
For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error URI: http://localhost:7349/Services/UserService.svc
Metadata contains a reference that cannot be resolved:
'http://localhost:7349/Services/UserService.svc'.
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
HTTP GET Error URI: http://localhost:7349/Services/UserService.svc
There was an error downloading 'http://localhost:7349/Services/UserService.svc'.
I have stripped a ton of lines from the error which is probably meant to render in a browser. Since I am running from within Visual Studio, I do not have a browser context.
Ok so here is my scenario.
I have made a WCF Library project. Configured my app.config file. I then created a new console application. Added my WCF Library project to the console app. Then I copied the config file over to my server console app. However, when I run the console application it throws an exception and essentially states that it cant see the app.config file. However, the app.config is clearly inside of the server console application. I can add my endpoints programmatically and make the service work. However, that is not my intention. Is there some sort of trick in order to get the ServiceHost to use the app.config, or more importantly the project to see the app.config?
My app.config
<configuration>
<configSections>
</configSections>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="serviceBehavior" name="Services">
<endpoint address="CompanyService" binding="netTcpBinding" bindingConfiguration=""
name="NetTcpBinding" contract="Services.ICompany" />
<endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8732/Services/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
My Host Service code:
using (ServiceHost host = new ServiceHost(typeof(Company))) {
host.Open();
Console.WriteLine("Press <ENTER> to terminate the host service");
Console.ReadLine();
}
It then throws this exception:
Unhandled Exception: System.InvalidOperationException: Service 'Services.Company' has zero application (non-infrastructure) endpoints. This might
be because no configuration file was found for your application, or because no
service element matching the service name could be found in the configuration fi
le, or because no endpoints were defined in the service element.
What are you naming the app.config file when you copy it over to the console app? There are specific rules that will need to be followed.
If the console app has an executable name of, e.g. "consoleapp.exe", then the app.config will have to have the name "consoleapp.exe.config"
Is the problem that you have called the file app.config, and not yourprogramname.exe.config?
#Jaochim The error says it's looking for a service named Services.Company while your config seems to have it attributed with name="Services" Try changing that.
I have written a application which is hosting a WCF Service.
And I try to run the application with this config.
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="MyApp.Service" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/service"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="MyApp.IService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
But it cause the application need to run as administrator.
Is it possible to run this application without admin privilege? (If possible, change the config only.) In addition, I also need to add service references in Visual Studio to write a client program. If possible, please keep the application can be added service references in Visual Studio 2010.
If you want to keep it on an HTTP binding so a nonadmin can run it, you'll need to add permissions using the command
netsh http add urlacl (see help for the rest of the params)
This will allow the user you specify to carve off a chunk of the URL-space for the machine. If you don't want to do this, you'll need to change to a different binding (netTcp, for instance) that doesn't require special privileges to listen.
This solution worked for me (using HTTP binding), open your service on this URL:
http://localhost:80/Temporary_Listen_Addresses/
Must admit that i found it on this site http://www.paraesthesia.com/archive/2010/06/11/developing-as-a-non-admin-testing-wcf-services.aspx/ after google-ing for some time...So credits to that guy.
Based on the comment to my other answer, you won't be able to do this with the built-in HTTP bindings- they're all based on HTTP.sys, which requires rights to be granted to non-admin users to register URLs. If your deployment scenario allows, consider switching to netTcpBinding instead- no permission issues there. Otherwise, you're SOL with the built-in bindings- you'd need to build a raw HTTP transport that's not based on HTTP.sys.