Solved

Error Hosting a WCF service library in IIS

Posted on 2015-02-22
6
439 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now