question

ArathiJinde-8885 avatar image
0 Votes"
ArathiJinde-8885 asked TimonYang-MSFT commented

System.BadImageFormatException : Could not load file or assembly

Hi,
I am referencing X64 Clr:Core .Net Core5 C++/CLI dll in an C# Test application
when running tests there is error BadImageFileFormatException

making the C# =>X64 and C++/CLI => X64 same
making C# =>X86 and C++/CLI =>win32 same
making C# =>32 (prefer 32bit AnyCPU) , C++/CLI=>win32 same
making C# =>AnyCPU and C++/CLI =>X64 same

TestExplorer test settings to X64

in all above cases it results in same error

Microsoft.TestPlatform.TestHost generates TestHost.dll and TestHost.exe are these dlls X64 versions

87734-image.png


these are the nuget packages installed

dotnet-csharp
image.png (49.5 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the reply
the solutions provided did not help :-((

TestHost.dll and TestHost.exe is there a way to target to X64
when I open the testHost.dll in dependency walker it shows that the CPU modules were different suspicious about this
same clr Core dll when referenced in WPF application is loading fine no issues here

0 Votes 0 ·

@ArathiJinde-8885
I suggest you ask your questions in the GitHub repository of .Net Core to get more expert help.

0 Votes 0 ·

0 Answers