I’ve started working on WCF for my final year project this week, in the process I encountered a few rather unhelpful issues with IIS and WCF:
When I navigated to my newly created web service I was confronted with the following error message:
The type ‘SMS.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 ‘SMS.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 'SMS.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) +51530 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1461 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651 [ServiceActivationException: The service '/SMS/Service1.svc' cannot be activated due to an exception during compilation.
The exception message is: The type 'SMS.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) +688590 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190 System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +310694 System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +94 |
—
Now as far as my source code was concerned everything was fine, my namespace and references were perfectly in order after several double checks; after hours of googling I finally discovered the solution – shockingly simple, all I needed to do was change the Virtual Directory in IIS into a Virtual Application:
Go to IIS Manager -> Expand your site -> Right Click Directory containing Web Service -> Select Convert to Application

IIS Screenshot 1 – Changing a Virtual Directory into an application.
Now being new to this I just clicked “Ok” on the following screen; unfortunately this produced the following error when navigating to the web service:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute ‘targetFramework’. Note that attribute names are case-sensitive.
Source Error:
Line 2: <configuration>
Line 3: <system.web>
Line 4: <compilation targetFramework=”4.0″ /> Line 5: <customErrors mode=”Off” />
Line 6: </system.web> |
—-
Fourty or so minutes of further googling uncovered the solution to this: I needed to set the Application Pool setting for the application to ‘ASP.NET v4.0′ – rather than the default 2.0; there are two ways to do this:
1. If you have not converted your virtual directory into an application:
Follow the same process as above, but rather than just clicking ok, click the “Select…” button and choose “ASP.NET v4.0″ from the drop down list shown:

IIS Screenshot 2 – Changing App Pool – Before Conversion
2. If you have converted your virtual directory into an application:
On the right hand pane of IIS Manager after selecting the Virtual Application, click “Basic Settings” and adjust the application as shown in the previous screenshot above.

IIS Screenshot 3 – Basic Settings
After completing this stage and accessing the web service once again, everything worked perfectly! Only took a good three hours to find the causes!