33

I have somewhat of a problem. My old webserver (windows 2003) have been replaced, with a 2008 R2. I have been given an admin account on it, and can do whatever I want, but I am no expert on this area. I configured the roles to have application developement and Web server (iis7).

BUT, my website runs .NET4, and the role only installed 3.5. So I have attempted to install .NET4 manually, on the server. My problem is, my website will not work on it, due to the System.ServiceModel section in my web.config. I have made sure it runs in .NET4 application pool.

I assume this is a WCF problem, but I can't grasp how to solve it. I have tried everything I found on google. aspnet_regis, ServiceModelReg.exe and so on. I have even tried re-installing the webserver role, but I still get this error, everytime I try to enter the sites setup.

I'm hoping there are some experts here, who know how to fix this.

Nicolai
  • 2,835
  • 7
  • 42
  • 52
  • 4
    Are you sure that the AppPool you are using is running on the correct framework version (4.0)? Found a link describing this issue: http://blog.benday.com/archive/2010/05/19/23278.aspx – Ozzy Jun 16 '11 at 07:54
  • [This](http://stackoverflow.com/a/4890368/664054) solved it for me – WhiteKnight May 01 '13 at 13:49
  • FWIW: I recently encountered the same issue, and resolved it through a fresh "Publish" of the application and then recycling the app pool. Hope this helps someone! :) – tklives Nov 03 '15 at 23:19

9 Answers9

32

I had the same error message, and it was because I was missing the .NET 3.5.1 framework on that server. Enabling that fixed my problem: http://blogs.msdn.com/b/sqlblog/archive/2010/01/08/how-to-install-net-framework-3-5-sp1-on-windows-server-2008-r2-environments.aspx

Mike Mooney
  • 11,729
  • 3
  • 36
  • 42
  • 16
    Thank you for the tip. For our case, it was caused by an application pool using .Net 2.0 instead of 4.0. – Hong Jun 18 '12 at 14:43
27

Go to the application pools in IIS and select the "Set Applicaiton Pool Default" [available in the right top corner], and check the version of .net framework.

Note: It'ld be selected as .net 4.0 version by default

kumaresh babu
  • 271
  • 3
  • 2
  • This answer started me on the right path. After I switched the .NET Framework version for the Application Pool from v2.0 to v4.0 the error went away. – Mitch Stewart Mar 10 '17 at 16:02
7

I had a different reason for getting this error.

This happened during migration of an MVC project from .Net 4.0 to 4.5, where the Microsoft.IdentityModel library is replaced with System.identityModel. In my case I had done all the necessary Web.Config migration steps listed here, but had forgotten to change the section name in configSections section:

<configSections>
 <section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>

As written here, the section definition should be:

<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Alex A.
  • 2,646
  • 22
  • 36
7

Apparently IIS7 needs a System.WebServer section, even if it is empty. Adding the following to my web.config file fixed my problem.

  <system.webServer>
  </system.webServer>
mwalker
  • 460
  • 4
  • 9
Nicolai
  • 2,835
  • 7
  • 42
  • 52
3

The issue for me was that WCF Services wasn't installed. Installing that fixed the problem for me: IS7: WCF Services - .SVC do not work.

Note that changing the application pool .NET version from 2.0 to 4.0 wasn't an option for me because the site needed to run on 2.0.

Sylvain Rodrigue
  • 4,751
  • 5
  • 53
  • 67
oonyalo
  • 466
  • 1
  • 6
  • 12
1

Because my project need run in .net 2.0 I must follow this link and it work for me with solution 3 : run file.js

http://blogs.msdn.com/b/wenlong/archive/2010/11/23/why-does-machine-config-contain-invalid-xml-content-after-installing-net-3-5-patches.aspx

Wolf
  • 6,361
  • 2
  • 28
  • 25
0

I had the same problem...I fixed it simply with:

aspnet_regiis.exe -i
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
usr4217
  • 420
  • 4
  • 18
0

For me, who didn't want to install the .NET Framework 3.5, the solution was to transcript the system.serviceModel section from the machine.config into my web.config file:

<configuration>
  <configSections>
    <sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <section name="behaviors" type="System.ServiceModel.Configuration.BehaviorsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="bindings" type="System.ServiceModel.Configuration.BindingsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="client" type="System.ServiceModel.Configuration.ClientSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="comContracts" type="System.ServiceModel.Configuration.ComContractsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="commonBehaviors" type="System.ServiceModel.Configuration.CommonBehaviorsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowDefinition="MachineOnly" allowExeDefinition="MachineOnly"/>
        <section name="diagnostics" type="System.ServiceModel.Configuration.DiagnosticSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="extensions" type="System.ServiceModel.Configuration.ExtensionsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="machineSettings" type="System.ServiceModel.Configuration.MachineSettingsSection, SMDiagnostics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowDefinition="MachineOnly" allowExeDefinition="MachineOnly"/>
        <section name="protocolMapping" type="System.ServiceModel.Configuration.ProtocolMappingSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="serviceHostingEnvironment" type="System.ServiceModel.Configuration.ServiceHostingEnvironmentSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowDefinition="MachineToApplication"/>
        <section name="services" type="System.ServiceModel.Configuration.ServicesSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="standardEndpoints" type="System.ServiceModel.Configuration.StandardEndpointsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        <section name="routing" type="System.ServiceModel.Routing.Configuration.RoutingSection, System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <section name="tracking" type="System.ServiceModel.Activities.Tracking.Configuration.TrackingSection, System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </sectionGroup>
  </configSections>
  <system.serviceModel>
    <!-- ... -->
  </system.serviceModel>
</configuration>
Rosberg Linhares
  • 3,537
  • 1
  • 32
  • 35
0

I had the same problem, I fixed it via the command prompt. Execute it as administrator, Go to folder \Windows\Microsoft.Net\Framework\V3.0(it was 3.0 in this case but it might be another version of .net Framework on another PC)\Windows Communication Foundation

Execute the command:

ServiceModelReg.exe -i
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Coskun Ozogul
  • 2,389
  • 1
  • 20
  • 32