After upgrading to .NET 4.0, I get the exception "Failed to load the file or assembly" System.Windows, Version = 2.0.5.0 ""

We recently updated our web application from 3.5 to 4.0. Now after logging in and loading the page using Microsoft ScriptManager, I get:

Could not load file or assembly "System.Windows, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e" or one of its dependencies. The system cannot find the specified file.

This only happens for the first time, reload the page, and everything works.

UPDATE: We have all Silverlight v4 projects. I found System.Windows.dll in the C: \ Program Files \ Reference Assemblies \ Microsoft \ Framework \ Silverlight \ v4.0 directory. Why is he looking for version 2.0?

Here is all the exception (edited and deleted folder paths)

Server error in application "/ test".

Could not load file or assembly "System.Windows, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e" or one of its dependencies. The system cannot find the specified file.

Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for more information about the error and its occurrence in the code.

Exception Details: System.IO.FileNotFoundException: Failed to load file or assembly "System.Windows, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e" or one of its dependencies. The system cannot find the specified file.

Source Error:

Line 450: <UC5: PageTitle ID = "PageTitle" runat = "server" />


Line 451: <UC2: PageTabs ID = "testPageTabs" runat = "server" />

Line 452: <asp: ID ScriptManager = "ScriptManager1" runat = "server" />

Line 453: <div id = "step1Div" style = "padding-top: 10px; padding-left: 10px" runat = "server">


Line 454: <asp: ValidationSummary ID = "displayValidationSummary" ValidationGroup = "displayCreateEditValidationGroup" runat = "server" />

Source file: c: {directories} \ Pages \ Administration \ DisplayCreateEdit.aspx Line: 452

Assembly loading schedule: The following information may be useful in determining why the assembly "System.Windows, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e" cannot be loaded.

WRN: Assembly binding registration is disabled. To enable assembly failure logging, set the registry value to [HKLM \ Software \ Microsoft \ Fusion! EnableLog] (DWORD) on 1. Note. There is some performance limitation associated with the assembly binding failure protocol. To disable this feature, delete the registry value [HKLM \ Software \ Microsoft \ Fusion! EnableLog].

Stack trace:

[FileNotFoundException: Failed to load the file or assembly "System.Windows, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e" or one of its dependencies. The system can not find the file specified.] System.ModuleHandle.ResolveType (RuntimeModule module, Int32 typeToken, IntPtr * typeInstArgs, Int32 typeInstCount, IntPtr * methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0 System.ModuleHandle.ResolveTypeHandleInternal (RuntimeModule module, Int32 typeToken , RuntimeTypeHandle [] typeInstantiationContext, RuntimeTypeHandle [] methodInstantiationContext) +180 System.Reflection.RuntimeModule.ResolveType (Int32 metadataToken, Type [] genericTypeArgumentRecTermTortCoreTementRecTermTementTeRmentTemerTementTeRmentmentTemerTementRutmentRetmentTementmententmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmentmetrtmentrtmentrtmentrtmentrtribentrementmentmentmetr assembly and amplifier; lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, boolean mustBeInheritable, Object [] attributes, IList derivedAttributes, RuntimeType & AttributeType, IRuntime MethodInfo & ter, Boolean & ctorHasParameters, Boolean & isVarArg) +115 System.Reflection.CustomAttribute.GetCustomAttributes (RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, attribute RuntimeTypeetleleoolefooToopelegetFetooleoolefooToopeleleooleFetooleFooToopeleleoolefetoolefetooleter Reflection.CustomAttribute.GetCustomAttributes (assembly RuntimeAssembly, RuntimeType caType) +103 System.Reflection.RuntimeAssembly.GetCustomAttributes (Boolean inherit) +33 System.Web.UI.AssemblyCache.GetAjaxFramework.Framework. get_DefaultAjaxFrameworkAssembly () +388 System.Web.UI.ScriptManager..ctor () +26 ASP.pages_administration_displaycreateedit_aspx .__ BuildControlScriptManager1 () in c: {directories} \ Pages \ Administration \ DisplayCreateEdit.aspx :_adp_dp_aspreation_dp_asp_dp_adpref_administration ControlContent1 (Control __ctrl) in c: {directories} \ Pages \ Administration \ DisplayCreateEdit.aspx: 9 System.Web.UI.CompiledTemplateBuilder.InstantiateIn (control container) +12 System.Web.UI.MasterPage.InstantiateInContentPlaceHolder (control contentPlaceHolder ITemplate) +87 ASP.master_master .__ BuildControlContentPlaceHolder1 () in c: {directories} \ Master.master: 28 ASP.master_master .__ BuildControlmasterForm () in c: {directories} \ Master.master: 13 ASP.master_master .__ BuildControlTree (master_master __ctrl) in c: {directories} \ Master.master: 1 ASP.master_master.FrameworkInitialize () in c: \ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET files \ zoning \ dff1a5fe \ 99aa3a7f \ App_Web_shgw15qp.4.cs: 0 System.Web.UI.UserControl.InitializeAsUserControlInternal () +35 System.Web.UI.MasterPage.CreateMaster (TemplateControl owner, HttpContext context, VirtualPath masterPageFile, content name IDictionaryTemplateCollection) +8832342 System.Web.UI.Page.get_Master () +54 System.Web.UI.Page.ApplyMasterPage () +15 System.Web.UI.Page.PerformPreInit () +45 System.Web.UI. Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +328


Version Information: Microsoft.NET Framework Version: 4.0.30319; ASP.NET Version: 4.0.30319.1

And system.web of our web.config:

<system.web> <pages validateRequest="false" buffer="true" theme="Summer" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"> <controls> <add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/> </controls> <tagMapping> <add tagType="System.Web.UI.WebControls.TextBox" mappedTagType="CleanTextBox"/> <add tagType="System.Web.UI.HtmlControls.HtmlTextArea" mappedTagType="CleanTextArea"/> </tagMapping> </pages> <compilation debug="true" targetFramework="4.0"> <assemblies> </assemblies> </compilation> <authentication mode="Forms"> <forms requireSSL="false" cookieless="UseDeviceProfile" loginUrl="~/Pages/Authentication/Login.aspx" timeout="60" defaultUrl="~/Pages/Authentication/AccountHome.aspx" slidingExpiration="true" name="sqlAuthCookie" protection="All"/> </authentication> <sessionState timeout="60" mode="StateServer" stateConnectionString="tcpip=localhost" stateNetworkTimeout="60" cookieless="false"/> <customErrors mode="RemoteOnly" defaultRedirect="~/Pages/Global/DefaultError.aspx"> <error statusCode="404" redirect="~/Pages/Global/404.htm"/> <error statusCode="403" redirect="~/Pages/Global/403.htm"/> </customErrors> <httpHandlers> <add path="*js.axd" verb="*" type="ScriptCompressorHandler"/> <add path="*css.axd" verb="*" type="CssCompressorHandler"/> <add path="*css" verb="*" type="CssCompressorHandler"/> <add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </httpHandlers> <httpModules> <remove name="WindowsAuthentication"/> <remove name="PassportAuthentication"/> <remove name="AnonymousIdentification"/> <remove name="RoleManager"/> <remove name="Profile"/> <remove name="ErrorHandlerModule"/> <add type="ScriptCompressorModule" name="ScriptCompressorModule"/> <add type="CssCompressorModule" name="CssCompressorModule"/> </httpModules> <machineKey validationKey="{key}" decryptionKey="{key}" validation="SHA1"/> <httpRuntime maxRequestLength="1048576" executionTimeout="3600" requestValidationMode="2.0"/> </system.web> 

See the same issue here and Microsoft Feedback / Error Report

Edit: I am running VS 2010, XP with IIS 5.0 (I missed Win 7 at work every day :-)). We have a web application running under a local instance of IIS, and not with Cassini. We deployed it on a test server, and I did not see an exception. After I installed CAC \ Program Files \ Reference Assemblies \ Microsoft \ Framework \ Silverlight \ v4.0 \ System.windows.dll in the GAC and then uninstalled it and did not see the same exception, although my colleague did not do this and still sees it from time to time. I think this only happens when the application restarts (which happens every time we restore the application when developing locally).

+6
source share
3 answers

It looks like one of the projects of your solution is referencing builds of the v2 system. Make sure that all of your projects and application pools are set to 4.0. You can set this in the project properties in Visual Studio.

(Note that you will have to rebuild your solution with the new settings if you have not already done so).

+2
source share

I had the same problems for a long time, but I just found some old Silverlight Assemblies in my bin folder, deleted those and voila .. the error went away

+1
source share

Adding AjaxControlToolkit.dll Link and Adding a Header

 <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> 

for aspx, which contains the script manager, solved the problem for me.

0
source share

All Articles