使用update-database的BadImageException

时间:2014-02-12 09:32:40

标签: c# entity-framework visual-studio-2013 ef-migrations

我有一个包含EF 5.0(目标框架4.0)迁移的程序集。

当我打开包管理控制台并输入'update-database'时,我得到一个BadImageException。 (注意:我在解决方案中有一个c ++本机库。)

我已经阅读了几篇有关此事的帖子,我试过了:

  1. 所有项目都有x64目标平台
  2. 解决方案平台是x64,所有项目都有x64作为配置
  3. 构建期间没有警告
  4. 但是......当我添加一个控制台应用程序时,使用DBMigrator类,迁移工作正常!

    会发生什么?

    (更新)

    在使用程序包管理控制台并使用“update-database”时,它似乎在EF / tools的程序包根目录中使用了一个名为“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> 
    

0 个答案:

没有答案