ASP.NET error - The 'System.ServiceModel/ServiceHostingEnvironment' configuration section cannot be created.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
March 18, 2009 20:37 by Jaroslav Kobližek

A month ago, I started to work on the customized version of BlogEngine.NET. By default it‘s being debugged on ASP.NET Development Server, but I tried to run it on my local IIS7 server.

Problem description:

When the application was starting I got a strange ASP.NET error that complains about missing information in machine.config in conjuction with Windows Communication Foundation.

 

The 'System.ServiceModel/ServiceHostingEnvironment' configuration section cannot be created. The Machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error.

 

 

The 'System.ServiceModel/ServiceHostingEnvironment' configuration section cannot be created. The Machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error.

 

I don’t know why this error has occurred, but I guess it must have been non-installed WCF on the system or even corrupted machine.config.

Solution:

1. First, try to do what the error says to do. Run "ServiceModelReg.exe –i" that is located in "C:\Windows\assembly\GAC_MSIL\ServiceModelReg\3.0.0.0__b03f5f7f11d50a3a" folder. You will get something like this:

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

c:\Windows\assembly\GAC_MSIL\ServiceModelReg\3.0.0.0__b03f5f7f11d50a3a>ServiceModelReg.exe -i
Microsoft(R) Windows Communication Foundation Installation Utility
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2123]
Copyright (c) Microsoft Corporation.  All rights reserved.

Installing: Machine.confi
g Section Groups and Handlers (WOW64)
Installing: Machine.config Section Groups and Handlers
Installing: System.Web Build Provider (WOW64)
Installing: System.Web Compilation Assemblies (WOW64)
Installing: HTTP Handlers (W
OW64)
Installing: HTTP Modules (WOW64)
Installing: System.Web Build Provider
Installing: System.Web Compilation Assemblies
Installing: HTTP Handlers
Installing: HTTP Modules
Installing: Protocol node for protocol net.tcp (WOW64)
Installing: TransportConfiguration node for protocol net.tcp (WOW64)
Installing: ListenerAdapter node for protocol net.tcp
Installing: Protocol node for protocol net.tcp
Installing: TransportConfiguration node for protocol net.tcp
Installing: Protocol node for protocol net.pipe (WOW64)
Installing: TransportConfiguration node for protocol net.pipe (WOW64)
Installing: ListenerAdapter node for protocol net.pipe
Installing: Protocol node for protocol net.pipe
Installing: TransportConfiguration node for protocol net.pipe
Installing: Protocol node for protocol net.msmq (WOW64)
Installing: TransportConfiguration node for protocol net.msmq (WOW64)
Installing: ListenerAdapter node for protocol net.msmq
Installing: Protocol node for protocol net.msmq
Installing: TransportConfiguration node for protocol net.msmq
Installing: Protocol node for protocol msmq.formatname (WOW64)
Installing: TransportConfiguration node for protocol msmq.formatname (WOW64)
Installing: ListenerAdapter node for protocol msmq.formatname
Installing: Protocol node for protocol msmq.formatname
Installing: TransportConfiguration node for protocol msmq.formatname
Installing: HTTP Modules (WAS)
Installing: HTTP Handlers (WAS)

c:\Windows\assembly\GAC_MSIL\ServiceModelReg\3.0.0.0__b03f5f7f11d50a3a>

Try the web site again if that helps.

2. If you still get the same error, go to Control Panel -> Program and Features. In the opened dialog click on “Turn Windows features on or off” and locate “Microsoft .NET Framework 3.0” that is probably unchecked. It contains Windows Communication Foundation items, so check it and click OK.

Turn Windows features on or off. Microsoft .NET Framework 3.0. Windows Communication Foundation.

 

It will take about 2 or 3 minutes till the system finishes the installing. If you don’t get any error and web site works, you are lucky one. I ended up with the error “An error has occurred. Not all of the features were successfully changed.” no matter what I’ve selected.

 

An error has occurred. Not all of the features were successfully changed.

 

 

After this unsuccessful installation the IIS is not working anymore. Am I kidding? No! Even system restart doesn’t help anyhow. IIS Manager only says: “There was an error when trying to connect. Do you want to retype your credentials and try again?” with additional detail “system.serviceModel cannot be read because it is missing a section declaration” on line 329 in “C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\web.config”.

 

There was an error when trying to connect. Do you want to retype your credentials and try again? system.serviceModel cannot be read because it is missing a section declaration

 

 

3. Fortunately, there is a way how to fix this -> Reinstallation of IIS.

Go back to “Turn Windows features on or off” and uncheck "Internet Information Services" (Framework 3.0 is probably already unchecked as well). Click OK. System will uninstall IIS. I recommend restart, just to be sure. After restart, go back to “Turn Windows features on or off” and check items in “Internet Information Service” as before. Also, check “Microsoft .NET Framework 3.0”. Click OK.

And voilà, it’s done. IIS is working and the web site as well.

It’s been quite painful to fix this error that came from nowhere. Hope this helps.