다음을 통해 공유


ServiceModelReg and FileLoadException

When ServiceModelReg runs and checks if a given section [group] handler is installed, if that handler points to a type in an assembly that cannot be found, ServiceModelReg may fail with a FileLoadFoundException. This has happened in the past when customers have not completely removed a previous version of WCF before installing a new drop (i.e. removed the files but not the machine.config settings). The new version's ServiceModelReg.exe cannot clean up the prior version entries nor can it register the new version's entries. The only workaround is to hand edit machine.config.

You can be certain that you have run into this issue if you run ServiceModelReg by hand with verbose output and get an error message similar to the following:

Error: System.IO.FileLoadException: Could not load file or assembly 'System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

File name: 'System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

The important thing to note from the error message surrounds the version of the System.ServiceModel assembly; 2.0.0.0. The version of the System.ServiceModel assembly released should read 3.0.0.0. The version 2.0.0.0 assembly was released as early CTP (Customer Technology Preview) releases. Thus, you would encounter this issue on a machine where an early CTP release of WCF was installed, but not completely uninstalled, prior to installing the official release of WCF.

To fix this issue you will need to hand edit your machine.config file. You will find this file at: %windir%\Microsoft.NET\Framework\v2.0.50727\config\machine.config (or if you are running on a 64-bit machine you will also have to edit %windir%\Microsoft.NET\Framework64\v2.0.50727\config\machine.config if it exists). Find any XML nodes in this file that refer to “System.ServiceModel, Version=2.0.0.0”, delete them and any child nodes. Save the file and retry running ServiceModelReg.exe. That should fix the issue.

Mark Gabarra

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm

Comments

  • Anonymous
    August 29, 2006
    Thanks.  I also had to remove some references to 'System.ServiceModel, Version=2.0.0.0' in %windir%Microsoft.NETFrameworkv2.0.50727configweb.config.

    Cheers

    David
  • Anonymous
    September 03, 2006
    The comment has been removed