Could not load EnterpriseLibrary assemblies when rendering view in MVC application
When rendering a view in an ASP.NET MVC application, I am getting the following Yellow Screen of Death. It will occur only once during the server lifecycle, subsequent renders work fine. I don't have any references to EnterpriseLibrary 4.0.0.0 within the application itself, which makes me think that the reference is outside of my application (machine.config or something similar). I have checked for EnterpriseLibrary references in C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config and C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config but neither had any reference. Any ideas?
Thanks in advance.
EDIT: The error is occurr开发者_如何学Cing on the following line: < asp:ScriptManager ID="ScriptManager2" EnablePartialRendering="false" runat="server" / > ., it previously appeared the error was occurring on the call to Telerik.
EDIT2: I can fix the error by removing < asp:ScriptManager ID="ScriptManager2" EnablePartialRendering="false" runat="server" /> which further points towards this being the problem. I am unsure as to why it is happening, however, and cannot claim I have an answer to the problem.
Here is the YSOD:
Server Error in '/services' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 153:<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
Line 154:
Line 155: < asp:ScriptManager ID="ScriptManager2" EnablePartialRendering="false" runat="server" / >
Line 156: <%= Html.Telerik().ScriptRegistrar() %>
Line 157:
Source File: c:\HIP\HWMI.API\HWMI.API.Web\Views\Membership\UserSubscriptionDetails.aspx Line: 155
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information ===
LOG: User = HWI\jyoung
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/HIP/HWMI.API/HWMI.API.Web/
LOG: Initial PrivatePath = C:\HIP\HWMI.API\HWMI.API.Web\bin
Calling assembly : Microsoft.Practices.EnterpriseLibrary.Security.Cache.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\HIP\HWMI.API\HWMI.API.Web\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot 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[] genericTypeArguments, Type[] genericMethodArguments) +192
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +115
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +426
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +33
System.Web.UI.AssemblyCache.GetAjaxFrameworkAssemblyAttribute(Assembly assembly) +76
System.Web.UI.ScriptManager.get_DefaultAjaxFrameworkAssembly() +388
System.Web.UI.ScriptManager..ctor() +26
ASP.views_membership_usersubscriptiondetails_aspx.__BuildControlScriptManager2() in c:\HIP\HWMI.API\HWMI.API.Web\Views\Membership\UserSubscriptionDetails.aspx:155
ASP.views_membership_usersubscriptiondetails_aspx.__BuildControlContent3(Control __ctrl) in c:\HIP\HWMI.API\HWMI.API.Web\Views\Membership\UserSubscriptionDetails.aspx:153
System.Web.UI.CompiledTemplateBuilder.InstantiateIn(Control container) +12
System.Web.UI.MasterPage.InstantiateInContentPlaceHolder(Control contentPlaceHolder, ITemplate template) +87
ASP.views_shared_site_master.__BuildControlScriptContent() in c:\HIP\HWMI.API\HWMI.API.Web\Views\Shared\Site.Master:389
ASP.views_shared_site_master.__BuildControlTree(views_shared_site_master __ctrl) in c:\HIP\HWMI.API\HWMI.API.Web\Views\Shared\Site.Master:1
ASP.views_shared_site_master.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\services\1a8554fb\b8d3a14c\App_Web_b1lugo2u.0.cs:0
System.Web.UI.UserControl.InitializeAsUserControlInternal() +35
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +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
ASP.NET MVC does not support the ScriptManager object. This makes sense as the ScriptManager is a Web Forms element and does not fall into the MVC world. As to why IIS attempts to load unreferenced assemblies when the ScriptManager bombs, I still do not know. It seems to load whatever is in the BIN directory (I had left over EntLib 4.0 assemblies in BIN) but then continues to load beyond this. I stopped trying to get to the bottom of where it was loading from when IIS returned "Could not load file or assembly DeployLX.Licensing.v4." I fixed by removing all ScriptManager references from the MVC application, as they were not required anyhow. If I was to use them there is a MVC ScriptManager available http://mvcscriptmanager.codeplex.com/
tl;dr; MVC does not support ScriptManager. I removed it.
精彩评论