Build/Test Issues

.Net Core 3.1 with WPF classes fail

Started by jotto on 3,773 views

I have recently converted a project from .Net Framework 4.8 to .Net Core 3.1. The tested classes are using BitmapSource from WPF.

When I try to run these tests, I'm getting the following exception:

System.IO.FileNotFoundException : Could not load file or assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

It seems like NCrunch doesn't resolve the WPF dependency somehow.

The test project file looks like this:

[h]<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
...
<UseWPF>true</UseWPF>
</PropertyGroup>
[/h]

Is this an NCrunch bug, or is there something I haven't configured properly?

Edited

I'm not an expert but I had a similar issue recently with my solution.

In NCrunch
Go to: Configuration > Build Settings > Copy referenced assemblies to workspace = True

Let me know if it worked for you :)
Thanks for following up guys. Unfortunately I'm getting the same error with "Copy referenced assemblies to workspace".
jotto wrote:Thanks for following up guys. Unfortunately I'm getting the same error with "Copy referenced assemblies to workspace".


Thanks for confirming this. Right now I believe it to be caused by this problem: https://forum.ncrunch.net/yaf_postst2892_Could-not-load-file-or-assembly-after-4-2-0-7-update.aspx

I recommend following the above thread for updates on the issue. Sadly, it's a tough one that might take us a while to crack. If you have the option, I recommend keeping your setup on an older toolset a little longer so you can still use NCrunch until we can fix the problem.
Would you mind testing the build below? I expect that it should work for your error too, if it doesn't not work could you please provide us with a small sample solution that reproduces the issue?

NCrunch_Console_4.3.0.1.msi
NCrunch_Console_4.3.0.1.zip
NCrunch_GridNodeServer_4.3.0.1.msi
NCrunch_GridNodeServer_4.3.0.1.zip
NCrunch_LicenseServer_4.3.0.1.zip
NCrunch_VS2008_4.3.0.1.msi
NCrunch_VS2010_4.3.0.1.msi
NCrunch_VS2010_4.3.0.1.zip
NCrunch_VS2012_4.3.0.1.msi
NCrunch_VS2012_4.3.0.1.zip
NCrunch_VS2013_4.3.0.1.msi
NCrunch_VS2013_4.3.0.1.zip
NCrunch_VS2015_4.3.0.1.msi
NCrunch_VS2015_4.3.0.1.msi.7z
NCrunch_VS2015_4.3.0.1.zip
NCrunch_VS2017_4.3.0.1.msi
NCrunch_VS2017_4.3.0.1.msi.7z
NCrunch_VS2017_4.3.0.1.zip
NCrunch_VS2019_4.3.0.1.msi
NCrunch_VS2019_4.3.0.1.msi.7z
NCrunch_VS2019_4.3.0.1.zip
It still fails. Fortunately it's easy to reproduce with a test :-)

[h]using System.Windows.Media;
using System.Windows.Media.Imaging;
using NUnit.Framework;

namespace MyNamespace
{
[TestFixture]
public class FailingTestClass
{
[Test]
public void FailingTest()
{
var bitmapSource =
BitmapSource.Create(10, 10, 96, 96, PixelFormats.Bgra32, null, new byte[10 * 10 * 4], 10 * 4);
}
}
}[/h]
Thanks!

I've got it reproduced and I will get back to you.
Would you checking if this build fixes the issue?

NCrunch_Console_4.3.0.2.msi
NCrunch_Console_4.3.0.2.zip
NCrunch_GridNodeServer_4.3.0.2.msi
NCrunch_GridNodeServer_4.3.0.2.zip
NCrunch_LicenseServer_4.3.0.2.zip
NCrunch_VS2008_4.3.0.2.msi
NCrunch_VS2010_4.3.0.2.msi
NCrunch_VS2010_4.3.0.2.zip
NCrunch_VS2012_4.3.0.2.msi
NCrunch_VS2012_4.3.0.2.zip
NCrunch_VS2013_4.3.0.2.msi
NCrunch_VS2013_4.3.0.2.zip
NCrunch_VS2015_4.3.0.2.msi
NCrunch_VS2015_4.3.0.2.msi.7z
NCrunch_VS2015_4.3.0.2.zip
NCrunch_VS2017_4.3.0.2.msi
NCrunch_VS2017_4.3.0.2.msi.7z
NCrunch_VS2017_4.3.0.2.zip
NCrunch_VS2019_4.3.0.2.msi
NCrunch_VS2019_4.3.0.2.msi.7z
NCrunch_VS2019_4.3.0.2.zip
Do you guys never take a break during weekends? :-D

Thanks -- it works now!
Thanks for the quick confirmation!

Post a reply

Log in to reply.