“An attempt was made to load a program with an incorrect format” even when the platforms are the same

前端 未结 20 2901
悲&欢浪女
悲&欢浪女 2020-11-22 13:57

I\'m calling functions from a 32-bit unmanaged DLL on a 64-bit system. What I get is:

BadImageFormatException: An attempt was made to load a program w

20条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 14:36

    We were having the same issue in .NET core. The solution was to download 32-bit .netcore runtime, and having your project target x86

    In your csproj file add

      
        x86  
      
    
      
        $(MSBuildProgramFiles32)\dotnet\dotnet    
      
    

    This was used for a Windows machine, you'd have to adjust paths and such for Linux/OSX

提交回复
热议问题