简体   繁体   中英

Binding failure was detected 'Microsoft.Practices.EnterpriseLibrary.Validation'

the building of this project is working on my friend's computer but not on mine.

on this return line:

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

i am getting the following error:

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.

here are all the references i have:

在此处输入图像描述

i did download the latest enterprise library and install it and i replaced all the DLLS in the above picture will all updated versions of them.

what am i doing wrong?

Alright I've found a solution. I never could accept turning off exceptions as an answer. Just seems somehow wrong....

What seems to be happening is that in previous assemblies, or previous versions of your current assembly, certain references were used externally. Even though your code may have long since abandoned those references, the names are still, some mysterious somewhere, being searched for in the assembly.

Go to your AssemblyInfo.cs files and find 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))]

Change the first location to 'None':

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //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))]

And keep your exceptions turned on. I will be posting this answer to various questions of this similar nature.

This is not a fatal error; it's a Managed Debugging Assistant, alerting you to a potential problem.
Go to Debug, Exceptions and uncheck it.

You can also just press F5 to continue execution.

I had a similar problem with one of the assemblies in my project. in my case it was caused by the assembly (dll) not being available in the bin/debug folder. This was solved by installing the referenced assembly in the parent project using NuGet, which created a dll in the bin/debug folder of the project upon rebuilding. What you can also try is to copy and paste the dll in the bin/debug folder of your solution from the original location of the dll.

Here are the step I took to troubleshoot the problem.

  • The MSDN documentation provides some suggestions on loading the fusion log to see which assembly bindings are active. the link to the MSDN documents I used are binding failure fusion log

(You have to start the fusion log viewer as an admin which allows you to change settings. in the fusion log viewer to display assembly bindings. There are enough resources online on how to work with the fusion viewer)

  • Figure out the location of the referenced dll and check whether it is there.
  • Copy and paste the dll in the right location.
  • rebuild solution

    ErrorHandling C#

Cleaning /bin folder helped me to solve this problem

Binding Failure fix: In Visual Studio 2015 -> Tab Debug-> Windows-> Exception Setting -> Output the setting board below right-bottom -> Managed Debugging Assistants -> Un-check BindingFailure

In my case it was Mysql package. Packages.config had an older version of it listing. I deleted it and reinstalled via nuget and it worked.

No need to uncheck debug exceptions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM