加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 18:24:14 所属栏目:百科 来源:网络整理
导读:这个项目的建设正在我朋友的电脑上工作但不在我的电脑上. 在这条回程线上: protected static Database Connection2{ get { try { return DatabaseFactory.CreateDatabase("HermesDB"); } catch (Exception e) { //Corpnet.Elmah.Error.Add(e); return null;
这个项目的建设正在我朋友的电脑上工作但不在我的电脑上.

在这条回程线上:

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 = MLABSagordon 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 SettingsagordonMy
DocumentsProjectsBulkUploadToLOMDatabaseBulkUploadToLOMDatabasebinDebugBulkUploadToLOMDatabase.vshost.exe.config
LOG: Using machine configuration file from
c:WINDOWSMicrosoft.NETFrameworkv2.0.50727configmachine.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))]

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读