BadImageException使用数据库更新(BadImageException using u

2019-10-19 08:33发布

我有一个组件与EF 5.0(目标框架4.0)在它的迁移。

当我打开包管理控制台,输入“更新数据库”我得到一个BadImageException。 (注:我在解决一个C ++本地库)。

我已阅读关于这一几个后,我尝试:

  1. 所有的项目都有64位目标平台
  2. 解决方案平台是64位,所有的项目都有64作为配置
  3. 构建过程中没有任何警告

但是...当我添加了一个控制台应用程序,使用DBMigrator类迁移工作正常!

怎么了 ?

(更新)

看来,使用打包管理控制台并使用“更新数据库”时,它使用的EF /工具包的根目录,叫“migrate.exe”的.exe文件。 这是名为.exe 32位和无法加载64个组件! 检查http://msdn.microsoft.com/en-us/data/jj618307.aspx )

使用VS2013,更新1。

异常详细信息:

PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.BadImageFormatException: Could not load file or assembly 'Progis.Kim.DataAccess.Systeem' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'Progis.Kim.DataAccess.Systeem'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.LoadAssembly()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindType[TBase](String typeName, Func`2 filter, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Progis.Kim.DataAccess.Systeem
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Progis.Kim.DataAccess.Systeem | Domain ID: 28
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/WS/ProgisKIM/Development/Progis/Progis.Kim.DataAccess.Systeem/bin/x64/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\WS\ProgisKIM\Development\Progis\Progis.Kim.DataAccess.Systeem\tmpEC23.tmp
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\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:/WS/ProgisKIM/Development/Progis/Progis.Kim.DataAccess.Systeem/bin/x64/Debug/Progis.Kim.DataAccess.Systeem.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Could not load file or assembly 'Progis.Kim.DataAccess.Systeem' or one of its dependencies. An attempt was made to load a program with an incorrect format.
PM> 
文章来源: BadImageException using update-database