简体   繁体   English

“无法加载文件或程序集'Microsoft.Practices.EnterpriseLibrary.Validation”异常

[英]“Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Validation” exception

I am currently getting the following exception while trying to use the Enterprise Library Validation Application Block: 我在尝试使用企业库验证应用程序块时遇到以下异常:

An error occurred creating the configuration section handler for validation: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 创建用于验证的配置节处理程序时出错:无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Validation,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35”或其依赖项之一。 The located assembly's 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) (来自HRESULT的异常:0x80131040)(C:\\ Documents and Settings \\ My Documents \\ Visual Studio 2008 \\ Projects \\ Testers \\ TestProject \\ web.config第12行)

I know what the exception is trying to tell me, but I can't figure out how to fix it. 我知道异常试图告诉我什么,但我无法弄清楚如何解决它。 I have only ever installed one version of the Enterprise Library, and this is it (4.1.0.0), so I don't see how it could be finding the wrong version, so I imagine it is then a dependency problem. 我只安装了一个版本的企业库,这就是它(4.1.0.0),所以我看不出它是如何找到错误的版本,所以我想它是一个依赖问题。 I have included the "Common", "Validation" and "ObjectBuilder2" DLLs from the Enterprise Library 4.1 as references in the project, so I'm not sure what else I'm missing. 我已经从企业库4.1中包含了“Common”,“Validation”和“ObjectBuilder2”DLL作为项目中的参考,所以我不确定我还缺少什么。 The documentation certainly seems to indicate this is all I need. 文档肯定似乎表明这就是我所需要的。

Is there any way to track down what the dependency problem is? 有没有办法找出依赖问题是什么?

If it helps, I am trying to use the Enterprise Library Configuration Tool to create a Validation Application Block rule set for validation of data in an Entity Framework entity. 如果有帮助,我尝试使用企业库配置工具创建验证应用程序块规则集,以验证实体框架实体中的数据。 I am using ASP.NET MVC in Visual Studio 2008. 我在Visual Studio 2008中使用ASP.NET MVC。

Thanks for any assistance/direction you can provide, 感谢您提供的任何帮助/指导,

Chris 克里斯

Turn on Fusion logging and see what assembly is being bound at runtime. 打开Fusion日志记录,查看在运行时绑定的程序集。

Hanselman had a post recently that should be helpful in enabling logging and examining the output. Hanselman最近有一篇文章,应该有助于启用日志记录和检查输出。

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

Another important distinction to make is that references that are added to the project are compile-time references and don't affect the way that code is bound at runtime other than to specify a strong name if a strongly named assembly was used. 要做的另一个重要区别是,添加到项目中的引用是编译时引用,并且不会影响代码在运行时绑定的方式,除非在使用强名称程序集时指定强名称。 In order to find out what is happening at runtime you need to look at the binding logs. 为了找出运行时发生的情况,您需要查看绑定日志。 The log should show you all of the attempts that the runtime makes at locating the assembly. 日志应显示运行时在查找程序集时所做的所有尝试。 If the assembly is not in the bin directory along with your exectuable, it is most likely looking in the GAC and finding a version that it does not expect. 如果程序集与您的exectuable一起不在bin目录中,则很可能会查找GAC并找到它不期望的版本。

Note that the compiler DOES NOT use the GAC when referencing assemblies. 请注意,编译器在引用程序集时不会使用GAC。 So most probably you have a different version used as a reference in the project than you have installed in the GAC. 因此,很可能您在项目中使用的不同版本比在GAC中安装的版本更多。

Also, it is very easy to find out what version you have installed in the GAC by looking in C:\\Windows\\assembly using Windows Explorer. 此外,通过使用Windows资源管理器查看C:\\ Windows \\ assembly,可以很容易地找到您在GAC中安装的版本。 The version that is specified in your error message will be the version that was referenced during compilation. 错误消息中指定的版本将是编译期间引用的版本。 If these versions don't match this could be your problem, assuming that Fusion is indeed looking in the GAC (which will be evident by looking in the Fusion log). 如果这些版本不匹配,那么这可能是您的问题,假设Fusion确实正在寻找GAC(通过查看Fusion日志可以看出这一点)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在WCF中加载文件或程序集'Microsoft.Practices.EnterpriseLibrary.Common - Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common in WCF 无法加载文件或程序集Microsoft.Practices.EnterpriseLibrary.Configuration - Could not load file or assembly Microsoft.Practices.EnterpriseLibrary.Configuration 无法加载文件或程序集'Microsoft.Practices.EnterpriseLibrary.Logging - Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging 无法加载文件或程序集'Microsoft.Practices.EnterpriseLibrary.Caching - Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Caching 检测到绑定失败“Microsoft.Practices.EnterpriseLibrary.Validation” - Binding failure was detected 'Microsoft.Practices.EnterpriseLibrary.Validation' C#无法加载文件或程序集'Microsoft.Practices.EnterpriseLibrary.Logging - C# Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging 无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Common”或其依赖项之一 - Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common' or one of its dependencies 无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Common,Version=6.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或 - Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or 无法加载文件或程序集“Microsoft.Practices.Unity” - Could not load file or assembly 'Microsoft.Practices.Unity' 无法加载文件或程序集 Microsoft.Practices.ServiceLocation,版本 = 1.3.0.0 - Could not load file or assembly Microsoft.Practices.ServiceLocation, Version=1.3.0.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM