Build/Test Issues

Using System.Xml in .NET Core 2 gives FileNotFoundException for System.Collections.NonGeneric

Started by thijstijsma on 9,064 views

I have a very simple test project with only one class as of now.
It's a .NET Core 2.0 library project.

I want to load an XmlSchema to pass to the class under test.

I get the following exception in XUnit, but was able to fix it by adding the NuGet package for "System.Collections.NonGeneric" in my test project.
The console application works fine without, is this something that needs to be added to NCrunch?

Kind regards,

Thijs Tijsma

System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.NonGeneric, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
at System.Xml.Schema.XmlSchema..ctor()
at System.Xml.Schema.Parser.StartParsing(XmlReader reader, String targetNamespace)
at System.Xml.Schema.Parser.Parse(XmlReader reader, String targetNamespace)
at System.Xml.Schema.XmlSchema.Read(XmlReader reader, ValidationEventHandler validationEventHandler)
at System.Xml.Schema.XmlSchema.Read(Stream stream, ValidationEventHandler validationEventHandler)
Hi, thanks for sharing this problem.

As long as this NuGet package has been added to the test project, there shouldn't be a resolution problem here for NCrunch.

Are you able to share this code with me? The assembly resolution system under .NET Core is so complex that it is unfortunately impossible to analyse these sorts of problems without a way to reproduce them.

You can submit code via the contact form.

Edited

I created and uploaded an example .NET Core project with xUnit.
That's great! Thanks for sending that through. I'll take a look and will get back to you soon.
Just to let you know I'm not in a hurry to get this fixed since I have a workaround. I mean it's probably weekend for you too!
Right, so this one doesn't look like it'll be easy to fix.

This is being caused by binding information crossing over from NCrunch's .NET Core 1.0 and 1.1 assemblies over into the .NET Core 2.0 environment. MS changed the dependency handling between 1.1 and 2.0.

This means that as soon as someone uses an assembly that is referenced by one of NCrunch's .NET Core assemblies but isn't directly declared as a Nuget package, there will be a resolution issue.

When you see this, the workaround for this is to just introduce a Nuget package reference for the assembly you need.

I'm looking at removing support for .NET Core 1.0 and 1.1, since trying to maintain these versions is proving to be very complex and it's causing problems under 2.0.
@Remco do we have a resolution time frame for this? I am experiencing a similar issue and the nuget hack isn't working (using .net core 2.1.1)
Hi, if you're experiencing this problem and the Nuget hack doesn't fix it, then you're probably experiencing a different problem.

If you can reduce it to a sample solution that you can share with me, I can help investigate further. You're welcome to submit code securely through the contact form.

Post a reply

Log in to reply.