Inexplicable assembly loading in WCF service (IIS 7)

I am working on a new WCF web service that will be hosted in an existing ASP.NET web application. When I try to run a .svc file for a service, I get an exception that it cannot find the file to build.

Failed to load file or assembly "System.IdentityModel, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089" or one of its dependencies. The system cannot find the specified file.

The problem is that this service does not reference this (specific) assembly anywhere. There is one reference project that loads System.IdentityModel, but references version 3.0.0.0. In fact, all these projects are aimed at runtime 3.5, and there are no links to any assemblies anywhere.

Here is the tag <compilation>from Web.config for the web application:

<compilation debug="true">
  <assemblies>
    <clear/>
    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  </assemblies>
</compilation>

Note. The tag <clear />was added later as an attempt to troubleshoot. Apparently, this did not affect the behavior. I added it because the .NET Compilation tab of IIS Configuration Manager gave me an error that was added to System.Data twice, although obviously not in this file. The addition <clear />took care of this for me, but I could not find duplicate it in Machine.config, and there is no base Web.config website, so I wonder if there could be something that could be causing the problem somewhere.

The server works with server 2008 with .NET 3.5 SP1. I get the same problem (although with System.Configurationinstead of IdentityModel, but nonetheless ...) on my local IIS installation, which is on Windows 7 x64 with .NET 4.0.

- , ( 3.0.0.0) , ?

+3
1

, , .

WCF , Type.GetType(string) , . Type.GetType(string) , :

  • ( )
  • mscorlib ( , )
  • ,

, .

- ( ) Assembly.GetType(string) ( ) , .

, 4.0, , . ServiceHost .svc , , , WCF .

+1

Source: https://habr.com/ru/post/1758254/


All Articles