Nunit test project cannot load System.Windows.Forms assembly to test a windows form based application targeting .Net 4.6.1

0

We have a Nunit test project targeting .Net Core 3.0 . This test project writes tests against a windows form based project which has target framework of 4.6.1 and a class library project also targeting 4.6.1.

Although I can write test for the class library project but am unable to test the windows form based project. While running test it always stops with an error,

"System.BadImageFormatException : Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058) ----> System.BadImageFormatException : Cannot load a reference assembly for execution"

Any thoughts?

c#
.net-core
nunit
tdd
.net-framework-version
asked on Stack Overflow Oct 10, 2019 by Jabed

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0