Solved

Error Hosting a WCF service library in IIS

Posted on 2015-02-22
6
460 Views
Last Modified: 2015-02-25
Hello,
I am having problems Hosting a WCF service in IIS. To try and resolve this I have gone back to basics and created a standard WCF service called WCFServiceLibrary6 which is unmodified and simply returns an integer. I have then Added a New Web Site called TestIISHosting2 ,removed the IService & Service from the website, modified the .svc file. However when I call this web service from IE using http://localHost/TestIISHosting2   I get an  "HTTP Error 500.19" error indicating that line 28  of the unmodified Web.config file is invalid.  

"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".

28:     <modules runAllManagedModulesForAllRequests="true"/>
 
I'm not sure what I have done incorrectly. I have documented all of the steps in the attached word document. Below are the Service1.svc & Web.config files.  Appreciate if someone can point me in the right direction

regards
Pat

See Attached word doc for more details

Service1.svc
<%@ ServiceHost Language="C#" Debug="true" Service="Service1" %>


web.config
<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="false" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
Hosting-a-WCF-service-in-IIS---example-o
0
Comment
Question by:pclarke7
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40625849
There are a few possibilities:

1) Add Application Development Features to IIS

2) Use Feature Delegation in IIS 7 to configure read/write access:

An Overview of Feature Delegation in IIS 7.0
http://www.iis.net/learn/manage/managing-your-configuration-settings/an-overview-of-feature-delegation-in-iis#02

3) Unlock handlers:

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers

Open in new window


4) Enabling ASP.NET 4.5 feature for Windows Server 2012 with IIS 8.

5) Enable HTTP Activation
0
 

Author Comment

by:pclarke7
ID: 40626728
Hi Bob,
Got through that error thanks but I am still struggling to get a basic WCF service hosted in IIS. Getting all sorts of error that I really don't know anything about. Is there any documentation out there that will give me a step by step instruction on how to host a simple WCF service in IIS7 and test that the hosted service is working. If there is then I would appreciate if you could point me in the right direction.

regards
Pat

 
Latest errors

Server Error in '/' Application.

The type 'Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 Exception Details: System.InvalidOperationException: The type 'Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

Source Error:


 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:



[InvalidOperationException: The type 'Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.]
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +90315
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1429
   System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +52
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +598

[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation.  The exception message is: The type 'Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +486568
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +174
   System.ServiceModel.Activation.ServiceHttpHandler.EndProcessRequest(IAsyncResult result) +6
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40626804
1) Did you rename anything?

2) I don't know of any single source for explaining errors.

3) WCF is a pain in the butt to configure.

4) What version of .NET do you have?

5) I am currently using WebAPI for a REST service, and it is a whole lot easier to work with.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 40626814
Walkthrough: Creating and Accessing WCF Services
https://msdn.microsoft.com/en-us/library/bb386386.aspx
0
 

Author Comment

by:pclarke7
ID: 40631699
Hi Bob,
got it sorted. One of my main problems was that the IIS_IUSRS group did not have the appropriate permissions for the Web.config file, To rectify this I went to the folder holding the folder holding the Web.config file and granted permission to  computername\IIS_IUSRS. I also located an excellent Youtube  https://www.youtube.com/watch?v=PBAs3zw6rq0
which stepped through the IIS hosting process step by step , which was just what I needed.

Thank you for you help on this.

regards
Pat
0
 

Author Closing Comment

by:pclarke7
ID: 40631701
thanks for all your effort - much appreciated
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Wav problem 4 26
C# parent child form 5 28
C# Desktop Application 3 35
HTML - Color not displaying correctly in EMAIL. 6 37
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question