Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design

Topics: Data Access Application Block, Enterprise Library Core
Jun 30, 2007 at 11:58 PM
I have a project that uses the enterprise library. it's working on a winxp iis 5.1 and a vista iis 7 box. i put it up on my production box which is w2k3 server with iis 6 and i get the following error:
Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=2.0.0.0

here's the weird thing, i have other applications running on this machine that use the enterprise library. why do you suppose i'm getting this?
Jul 1, 2007 at 12:01 AM
this is my stack trace:

PolicyException: Required permissions cannot be acquired.
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +2737813
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57

FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32

ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +596
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +3487289
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +46
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +177
System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +267
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +36
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +429
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +73
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +580
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +93
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +111
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +54
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +139
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +120
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Jul 1, 2007 at 12:10 AM
also, i can get the error to repro on my vista/iis7 box if i add a <trust level=""/> tag to the web.config and set the level to anything (Low, Medium, or High).
Jul 1, 2007 at 12:22 AM
Edited Jul 1, 2007 at 1:12 AM
and, my machine.config file has <trust level="Full" originUrl="" />

also, i'm using the Enterprise Lib 3.1 May release DLLs
Jul 2, 2007 at 2:34 PM
Hi,

Why do you need to load the Configuration.Design assembly in a web application? In any case, you mention you're using the 3.1 release DLLs but you get an error for failure to load "'Microsoft.Practices.EnterpriseLibrary.Configuration.Design, Version=2.0.0.0" so there is some version mixup going on there. I don't recall if version 2.0 of assembly Configuration.Design demanded full trust, 3.1 doesn't. It would be great if you could access the details of the exception to determine which permission is not granted on anything but full trust.

About why it doesn't it work on your production machine, is it possible there is an override for the trust level on your web app's parent folder?

Fernando
Jul 2, 2007 at 6:27 PM
yeah, i don't need it. i removed it and was still getting the error, turned out there was a nameserver issue and the IP was pointing to the wrong website, where i had first tried to post this (to a shared host).

anyway, got it resolved, thanks.
Aug 4, 2007 at 2:49 AM
I am having same issue as bryanc have...any one has solution to resolve it...I am getting this error in hosting web site which has Windows Server 2003.
Aug 4, 2007 at 3:28 AM
question for you jsquare:
>> are you in a shared host environment? if so, have they locked down your trust level?
>> do you have <trust level="full"/> in the machine.config?
>> what version of the dlls are you hosting?
Aug 4, 2007 at 2:34 PM
Hi Bryanc,

I am using Enterprize Jan Library 2006. I am not sure if shared host has locked down my trust level and even don't know about <trust level='full' /> in the machine config.

Thanks
JSQUARE
Aug 4, 2007 at 4:54 PM
if you are in a shared hosting scenario, then it's likely your host has restricted the trust level at a machine level to medium. i think some of the dlls in the 2006 library release need trust level=full to work, but i think the 2007 stuff is all medium trust.
Aug 4, 2007 at 6:26 PM
Thanks Bryanc..

I will check it out

Jsquare
Aug 4, 2007 at 7:12 PM
So dows it mean host can not change the setting in machine.config only for me..are there any other ways ...can i override any settings in my web.config
Aug 5, 2007 at 5:30 PM
setting it in machine.config means all apps on that machine inherit that setting. if they haven't marked that section as "locked," then you can override it on an app by app basis in app.config. however, it's likely that they've locked it down to medium or lower trust, since that's fairly standard practice for shared hosts. high or full trust allows you to do things that could severely destabilize the machine and crash other apps.

with that said, i believe the 2007 releases run under medium trust, so you may look at trying to run those instead.
Aug 6, 2007 at 2:29 PM
Hi,

There is a "partial trust" patch for EntLIb 2, available from http://www.codeplex.com/entlib/Release/ProjectReleases.aspx?ReleaseId=1339. This patch has been integrated to EntLib 3.0, but it will only work with the unsigned assemblies you can build from the source code.

Regards,
Fernando