在这条回程线上:
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))]
并保持您的例外开启!我将把这个答案发给这个类似性质的各种问题.