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 http://www.microsoft.com/info/cpyright.htm


 

Comments (2)

  1. David Brazier says:

    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

  2. Rich says:

    During the setup of the WinFX runtime components I am getting a System.MissingMethodException from ServiceModelReg.exe. The install then rollsback and uninstalls. This has caused a lot of trouble with trying to get winfx installed on my machine. Do you have any suggestions?

    You can reach me at: rich@nospam_masterplansoftware.com

    (don’t forget to delete ‘nospam_’ of course)

    Thanks,

    Rich Burgess