c# – 检测到绑定失败’Microsoft.Practices.EnterpriseLibrary.Validation’

这个项目的建设正在我朋友的电脑上工作但不在我的电脑上.

在这条回程线上:

protected static Database Connection2
{
    get
    {
        try
        {
            return DatabaseFactory.CreateDatabase("HermesDB");
        }
        catch (Exception e)
        {
            //Corpnet.Elmah.Error.Add(e);
            return null;
        }
    }
}

我收到以下错误

The assembly with display name
‘Microsoft.Practices.EnterpriseLibrary.Validation’ Failed to load in
the ‘Load’ binding context of the AppDomain with ID 1. The cause of
the failure was: System.IO.FileNotFoundException: Could not load file
or assembly ‘Microsoft.Practices.EnterpriseLibrary.Validation’ or one
of its dependencies. The system cannot find the file specified. File
name: ‘Microsoft.Practices.EnterpriseLibrary.Validation’

=== Pre-bind state information === LOG: User = MLABS\agordon LOG: displayName = Microsoft.Practices.EnterpriseLibrary.Validation
(Partial) LOG: Appbase = file:///C:/Documents and Settings/agordon/My
Documents/Projects/BulkUploadToLOMDatabase/BulkUploadToLOMDatabase/bin/Debug/
LOG: Initial PrivatePath = NULL Calling assembly :
Microsoft.Practices.EnterpriseLibrary.Common,Version=5.0.414.0,
Culture=neutral,PublicKeyToken=null.
=== LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Documents and Settings\agordon\My
Documents\Projects\BulkUploadToLOMDatabase\BulkUploadToLOMDatabase\bin\Debug\BulkUploadToLOMDatabase.vshost.exe.config
LOG: Using machine configuration file from
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private,
custom,partial,or location-based assembly bind). LOG: Attempting
download of new URL file:///C:/Documents and Settings/agordon/My
Documents/Projects/BulkUploadToLOMDatabase/BulkUploadToLOMDatabase/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Validation.DLL.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/agordon/My
Documents/Projects/BulkUploadToLOMDatabase/BulkUploadToLOMDatabase/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Validation/Microsoft.Practices.EnterpriseLibrary.Validation.DLL.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/agordon/My
Documents/Projects/BulkUploadToLOMDatabase/BulkUploadToLOMDatabase/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Validation.EXE.
LOG: Attempting download of new URL file:///C:/Documents and
Settings/agordon/My
Documents/Projects/BulkUploadToLOMDatabase/BulkUploadToLOMDatabase/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Validation/Microsoft.Practices.EnterpriseLibrary.Validation.EXE.

这里有我所有的参考资料:

我确实下载了最新的企业库并安装它,我在上面的图片中替换了所有更新版本的DLLS.

我究竟做错了什么?

解决方法

好吧,我找到了解决方案.我永远不能接受将异常作为答案.只是看起来有些不对……

似乎正在发生的事情是,在以前的程序集或当前程序集的先前版本中,某些引用是在外部使用的.尽管你的代码可能早已放弃了这些引用,但在程序集中搜索名称仍然是某些神秘的东西.

转到AssemblyInfo.cs文件并找到ThemeInfo:

[assembly: ThemeInfo(
ResourceDictionaryLocation.ExternalAssembly,//where theme specific resource dictionaries are located
//(used if a resource is not found in the page,// or application resource dictionaries)
ResourceDictionaryLocation.sourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,// app,or any theme specific resource dictionaries))]

将第一个位置更改为“无”:

[assembly: ThemeInfo(
ResourceDictionaryLocation.None,or any theme specific resource dictionaries))]

并保持您的例外开启!我将把这个答案发给这个类似性质的各种问题.

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...