Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 613
  • Last Modified:

Error Hosting a WCF service library in IIS

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
pclarke7
Asked:
pclarke7
  • 3
  • 3
1 Solution
 
Bob LearnedCommented:
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
 
pclarke7Author Commented:
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
 
Bob LearnedCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Bob LearnedCommented:
Walkthrough: Creating and Accessing WCF Services
https://msdn.microsoft.com/en-us/library/bb386386.aspx
0
 
pclarke7Author Commented:
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
 
pclarke7Author Commented:
thanks for all your effort - much appreciated
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now