简体   繁体   English

Microsoft.CSharp库中的BadImageFormat异常

[英]BadImageFormat Exception at Microsoft.CSharp library

I'm having little problem running my C# application after switching to Windows 8.1 from 8. The problem is that I get this exception from title and there's not much help online. 从8开始转换到Windows 8.1后,我在运行我的C#应用​​程序时遇到的问题很小。问题是我从标题中获得了这个异常并且在线帮助不大。 I tried to pinpoint the problem and it seems like my x64 application is trying to call x86 CSharp library. 我试图找出问题,似乎我的x64应用程序试图调用x86 CSharp库。 The reference in project leads to a DLL file, that upon calling x64 dumpbin program with /headers parameter outputs: 项目中的引用导致DLL文件,在使用/ headers参数输出调用x64 dumpbin程序时:

Dump of file Microsoft.CSharp.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
             14C machine (x86)
               3 number of sections
        4FFA5C64 time date stamp Mon Jul 09 06:21:56 2012
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
            2022 characteristics
                   Executable
                   Application can handle large (>2GB) addresses
                   DLL

Notice the machine is x86, while the application is running in x64 (checked with Environment.Is64BitProcess). 请注意,该计算机是x86,而应用程序在x64中运行(使用Environment.Is64BitProcess检查)。 This might be the problem I'm facing, however I can't find way to solve it - there seems to be no x64 .Net libraries installed. 这可能是我面临的问题,但是我找不到解决方法 - 似乎没有安装x64 .Net库。 The only ones I have found are at: C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework . 我找到的唯一的是: C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework Or maybe I'm completely off and there's some other problem. 或者也许我完全失去了,还有一些其他问题。 Anyway the exception occurs at startup in one of constructors and full detail is: 无论如何,异常发生在一个构造函数的启动时,完整的细节是:

Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
"Could not load file or assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest."

Edit: 编辑:

While still panicking, I solved this by downloading CSharp.dll and replacing the dummy 0-byte file in path shown in answer by it. 虽然仍然恐慌,我通过下载CSharp.dll并在其回答中显示的路径中替换虚拟0字节文件来解决这个问题。

The module was expected to contain an assembly manifest 该模块应该包含一个程序集清单

You've been looking at a reference assembly, it is not the one that's actually loaded when you run your program. 您一直在查看引用程序集,它不是运行程序时实际加载的程序集。 Microsoft.CSharp.dll is stored in the GAC, put there by the .NET installer. Microsoft.CSharp.dll存储在GAC中,由.NET安装程序放在那里。 You can see the file by navigating to c:\\windows\\microsoft.net\\assembly\\gac_msil\\microsoft.csharp. 您可以通过导航到c:\\ windows \\ microsoft.net \\ assembly \\ gac_msil \\ microsoft.csharp来查看该文件。 Keep clicking until you get to the file. 继续单击直到找到该文件。

The exception message is a very unhealthy one, it doesn't recognize the DLL as a .NET assembly. 异常消息是一个非常不健康的消息,它不会将DLL识别为.NET程序集。 There are few decent explanations for that, other than the file being corrupted. 除了文件被破坏之外,没有什么可行的解释。 File corruption is always bad news, a strong hint that your hard-disk is failing. 文件损坏总是坏消息,强烈暗示您的硬盘出现故障。 You'll need to get it fixed, follow-up if necessary at superuser.com 您需要修复它,必要时在superuser.com进行跟进

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法识别Microsoft.CSharp参考 - Microsoft.CSharp reference not recognized 无法找到参考组件Microsoft.CSharp - Reference Component Microsoft.CSharp could not be found 为什么面向.Net Standard的库需要Microsoft.Csharp - Why do libraries targeting .Net Standard need Microsoft.Csharp 发现无法解决的不同版本的“Microsoft.CSharp”之间的冲突 - Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved C#Compiler-as-a-Service:Mono.CSharp与Microsoft.CSharp - C# Compiler-as-a-Service: Mono.CSharp vs Microsoft.CSharp 使用不是管理员组成员的用户登录时无法加载文件或程序集“Microsoft.CSharp” - Could not load file or assembly 'Microsoft.CSharp' when logged in with user which is not a member of administrator group Xamarin Android 错误“无法解析引用:`System.Dynamic`,由`Microsoft.CSharp` 引用” - Xamarin Android Error "Can not resolve reference: `System.Dynamic`, referenced by `Microsoft.CSharp`" 尝试导出 fastreport 报告时无法找到元数据文件“Microsoft.CSharp”错误 - Getting a Metadata file 'Microsoft.CSharp' could not be found error upon trying to export a fastreport report 缺少编译器所需的成员,但已添加 Microsoft.CSharp package - Missing compiler required member but have already added Microsoft.CSharp package NuGet软件包管理器:'AutoMapper'已经具有为'Microsoft.CSharp'定义的依赖项 - NuGet Package Manager: 'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM