"Failed to load file or assembly" Microsoft.Practices.EnterpriseLibrary.Validation Exception "

I am currently getting the following exception when trying to use the application block to verify the health of the Enterprise Library:

An error occurred while creating the configuration section handler for verification: the file or assembly "Microsoft.Practices.EnterpriseLibrary.Validation, Version = 4.1.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35" or one of its dependencies could not be loaded. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C: \ Documents and Settings \ My Documents \ Visual Studio 2008 \ Projects \ Testers \ TestProject \ web.config line 12)

I know that the exception is trying to tell me, but I cannot figure out how to fix it. I only ever installed one version of Enterprise Library, and that is it (4.1.0.0), so I don’t see how it can find the wrong version, so I assume this is a dependency problem. I included the "Common", "Validation" and "ObjectBuilder2" libraries from the Enterprise Library 4.1 as references in the project, so I'm not sure what else is missing. The documentation undoubtedly indicates that this is all I need.

Is there any way to track that the problem is addiction?

If this helps, I try to use the enterprise library configuration tool to create a validation application block rule that is installed to validate data in the Entity Framework entity. I am using ASP.NET MVC in Visual Studio 2008.

Thanks for any help / direction you can provide,

Chris

+7
c # asp.net-mvc enterprise-library validation-application-bl
source share
2 answers

Turn on Fusion logging and see which assembly is bound at runtime.

Hanselman recently posted a post that should be useful for enabling logging and examining results.

http://www.hanselman.com/blog/CommentView.aspx?guid=3654c8f3-c5c3-4dee-a01f-c9a8da3ef2fa

Another important difference is that the links that are added to the project are compile-time links and do not affect the way the code is bound at run time, except to specify a strong name if a strongly named assembly was used. To find out what happens at runtime, you need to look at the bind logs. The log should show you all attempts to complete the assembly during assembly of the assembly. If the assembly is not in the bin directory with your exectuable, it will most likely look in the GAC and find a version that it does not expect.

Note that the compiler does NOT use the GAC when referencing assemblies. Therefore, most likely, you have a different version, used as a reference in the project, than you installed in the GAC.

It is also very easy to find out which version you installed in the GAC by looking in C: \ Windows \ assembly using Windows Explorer. The version indicated in your error message will be the version referenced at compile time. If these versions do not match, this may be your problem, assuming that Fusion is really looking in the GAC (which will be obvious when viewed in the Fusion log).

+5
source share

Tom Hollander , one of the developers of the Enterprise Library, wrote an interesting article about this on his blog: Avoid configuration errors with incompatible copies of the Enterprise Library . Be sure to read for everyone starting with the Enterprise Library.

+2
source share

All Articles