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

entity-framework – 无法启用 – 迁移.引发System.BadImageForm

发布时间:2020-12-16 03:38:48 所属栏目:asp.Net 来源:网络整理
导读:我无法启用EF迁移! 使用包管理器控制台,它会抛出以下内容: PM启用的迁移 System.BadImageFormatException:无法加载文件或程序集“MyApp”或其依赖项之一.索引未找到. (HRESULT异常:0x80131124) 文件名:’MyApp’— System.BadImageFormatException:找
我无法启用EF迁移!

使用包管理器控制台,它会抛出以下内容:

PM>启用的迁移
System.BadImageFormatException:无法加载文件或程序集“MyApp”或其依赖项之一.索引未找到. (HRESULT异常:0x80131124)
文件名:’MyApp’—> System.BadImageFormatException:找不到索引. (HRESULT异常:0x80131124)
???在System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)
???在System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,Boolean suppressSecurityChecks)
???在System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,RuntimeAssembly reqAssembly,Boolean suppressSecurityChecks)
???在System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Boolean forIntrospection)
???在System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Boolean forIntrospection)
???在System.Reflection.Assembly.Load(String assemblyString)
???在System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.LoadAssembly()
???at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindType [TBase](String typeName,Func2 filter,Func2 noType,Func3 multipleTypes,Func3 noTypeWithName,Func3 multipleTypesWithName)
???在System.Data.Entity.Migrations.Design.ToolingFacade.GetContextTypeRunner.RunCore()
???在System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()

Could not load file or assembly 'MyApp' or one of its dependencies. Index not found. (Exception from HRESULT: 0x80131124)

也:
1.我的默认项目(在PM CONSOLE中)是’MyApp’
2.解决方案只有’MyApp’
3.继承自DbContext的类位于“MyApp.Models”中
4.我还尝试创建一个新的解决方案,然后将粘贴的所有类复制到它,它会抛出相同的错误

怎么了?
我曾经在此项目中启用了迁移,但两天后我删除了所有迁移内容,因为它不是必需的.但现在我真的需要它们

解决方法

我刚遇到同样的问题.

System.BadImageFormatException的原因是因为我依赖于x64 DLL(在我的情况下是Magick.NET-x64.dll).强制项目以32位构建解决了它.

>选择您的WebProject
>转到“属性”
>选择“构建”选项卡
>更改平台目标:从x64到任何CPU

希望这有助于其他人.

(编辑:李大同)

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

    推荐文章
      热点阅读