TypeLoadException after upgrading to .NET 3.5

Dec 7, 2008 at 3:41 AM
Edited Dec 7, 2008 at 8:05 AM
[Update: Upgrade to EntLib 4.1 did not solve the problem Same error is returned. See the reply to this post for more details.]

[Update: I'm going to upgrade to EntLib 4.1 as I suspect that is the issue. Just hope it is not as painful as the 2.x to 3.x upgrade was.]

I recently got a new computer and during the process upgraded to VS2K8 and .NET 3.5. Now when I try to open my web.config with EntLibConfig.exe for EntLib 3.1 I get a type load exception. I've checked my web.config a dozen time manually and searching and absolutely do not have a reference anywhere in the config to Version=1.0.61025.0 of system.web.extensions. All references are to version 3.5.

System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount)
   at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Assembly assembly, RuntimeType caType)
   at System.Reflection.Assembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationDesignManagerDomain.Load(Assembly assembly)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationDesignManagerDomain.LoadFrom(String path)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationDesignManagerDomain.Load()
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationUIHierarchy.Load()
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationUIHierarchy.Open()
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.OpenConfigurationApplicationNodeCommand.OpenFile()
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.OpenConfigurationApplicationNodeCommand.ExecuteCore(ConfigurationNode node)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationNodeCommand.Execute(ConfigurationNode node)
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Console.MainForm.OpenApplication()
   at Microsoft.Practices.EnterpriseLibrary.Configuration.Console.MainForm.OnToolbarButtonClick(Object sender, ToolBarButtonClickEventArgs e)
   at System.Windows.Forms.ToolBar.OnButtonClick(ToolBarButtonClickEventArgs e)
   at System.Windows.Forms.ToolBar.WmReflectCommand(Message& m)
   at System.Windows.Forms.ToolBar.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Dec 7, 2008 at 8:12 AM
After upgrading to entlib 4.1 I am getting the same error, i.e. typeloadexception on system.web.extensions

I then create a brand new asp.net project using VS2K8 and then tried to open the web.config from entlib and could not because it got the same typeload exception. I don't know why entlibconfig is looking for version 1.0.6.xxx of system.web.extensions when it is referenced nowhere in the auto-generated web.config.

<?xml version="1.0"?>

<configuration>

    <configSections>
      <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
          <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
            <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          </sectionGroup>
        </sectionGroup>
      </sectionGroup>
    </configSections> 

 
    <appSettings/>
    <connectionStrings/>
 
    <system.web>
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
        <compilation debug="false">

          <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.DataSetExtensions, 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"/>
          </assemblies>

        </compilation>
        <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
        <authentication mode="Windows" />
        <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->

      <pages>
        <controls>
          <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </controls>
      </pages>

      <httpHandlers>
        <remove verb="*" path="*.asmx"/>
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
      </httpHandlers>
      <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </httpModules>

    </system.web>

    <system.codedom>
      <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                  type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <providerOption name="CompilerVersion" value="v3.5"/>
          <providerOption name="WarnAsError" value="false"/>
        </compiler>
     </compilers>
    </system.codedom>
   
    <!--
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false"/>
      <modules>
        <remove name="ScriptModule" />
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </modules>
      <handlers>
        <remove name="WebServiceHandlerFactory-Integrated"/>
        <remove name="ScriptHandlerFactory" />
        <remove name="ScriptHandlerFactoryAppServices" />
        <remove name="ScriptResource" />
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
             type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
             type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </handlers>
    </system.webServer>

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
      </assemblyBinding>
    </runtime>

</configuration>

Dec 7, 2008 at 8:28 AM
I tried opening one of the config files that are shipped with entlib 4.1. Here is the file from the C:\EntLib41Src\Quick Starts\Configuration-Migration\CS\ConfigurationMigrationQuickStart\web.config file. Sure isn't much in it and certainly no references to system.web.extenstions.

<configuration>
  <configSections>
    <section name="EditorSettings" type="ConfigurationMigrationQuickStart.EditorFontData, ConfigurationMigrationQuickStart, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null" />
  </configSections>
  <EditorSettings name="Verdana" size="24" style="2" />
</configuration>
Dec 7, 2008 at 1:59 PM

Hi,

Can you post you post your repro steps? Also what's the prerequisites installed.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 7, 2008 at 11:10 PM
What I was doing was taking all of the entlib binaries including the entlibconfig.exe and copying those into my project Library folder. I was then running entlibconfig from my Library directory. This is the way I've always done it with 3.1. For some reason with 4.1 its not working and I get the above error. However, the entlibconfig tool runs fine when I run it from the c:\entlib4src directory. Not sure why it isn't running from my library directory Maybe I have something lingering in there from 3.1 that is causing it to fail.
Dec 8, 2008 at 9:10 AM
Hi royhiggs,
I was not able to replicate your error, however strange issues occur when we use incompatible versions of libraries and entlibconfig.exe in our application. Did you copied the entlib biraries from c:\entlib4src OR from the bin of entlib installation folder( usually from C:\Program Files\<entlib4 dir>\bin)?
If you copied the libraries from c:\entlib4src\bin, ensure that the project references the same version too. You  may need to re-add/update your project references to point to the copied version just to make sure. Next is that you use the entlibconfig.exe from the same bin directory where you copied your assemblies.In this case, use the one copied from c:\entlib4Src\bin\EntLibConfig.exe. Hope this helps.

Rhea Echevarria
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com