Service Fabric System.BadImageFormatException

本秂侑毒 提交于 2019-11-30 05:20:13

问题


I downloaded the latest version of Service Fabric SDK 2.4.164 and try to create a new simple stateless service. Build succeeded but when I run it to debug I got:

An unhandled exception of type 'System.BadImageFormatException' occurred in Unknown Module.

Additional information: Could not load file or assembly 'System.Fabric, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. An attempt was made to load a program with an incorrect format.

What is the problem? Please help to solve that. Let me know if I have to add more informations


回答1:


Azure Service Fabri only supports x64 platform. It seems you're using some x86 tools. If you have installed dotnet (CLI) tools for x64 and x86 then check Path environment variable. The first one should be path to the x64 components, it helped me to solve the same issue




回答2:


All Service Fabric assemblies are compiled to x64. Make sure your project is also targeting x64, and not AnyCPU.

The best way to do this is to go into Configuration Manager in Visual Studio, create x64 build configurations for each project, and then delete all of the AnyCPU build configurations. That's how the Service Fabric project templates in Visual Studio are set up. But if you create a project from a different template, like Console Application or Class Library, it will be created with an AnyCPU build configuration - you need to change that to x64 if you reference any Service Fabric assemblies.



来源:https://stackoverflow.com/questions/42307850/service-fabric-system-badimageformatexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!