Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

System.MissingMethodException (.net standard 2.0 class lib + 4.7 test project)
MarcinG
#1 Posted : Thursday, January 18, 2018 10:17:37 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/18/2018(UTC)
Posts: 2
Location: Poland

Thanks: 1 times
Hi,

We have problem with NCrunch when combining .NetStandard 2.0 ClassLibrary and test project targeting .Net Framework 4.7. NCrunch have been working great with all tests which we wrote untill today :) I used tuples and bam! I got; System.MissingMethodException.

How to reproduce:
1. Create new .NetStandard 2.0 library
2. Add code:

Code:
    public class Class1
    {
        public (List<(int, string)>, List<(int, string)>) GetTuple()
        {
            return (new List<(int, string)> {(1, "test")}, new List<(int, string)> { (1, "test2") });
        }
    }


3. Add ClassLibrary targeting .netframework 4.7
4. Install xunit
5. add reference to the first project.
6. Add code:

Code:
    public class Class1Tests
    {
        [Fact]
        public void doesItWork()
        {
            var cut = new Class1();
            cut.GetTuple();
        }
    }

7. NCrunch fails.

The test passes in resharper test explorer as well as in VS test explorer. The issue disappears if you will set "Pre-load all assembly references into test environment" but this shouldn't be necessary, should it?
IDE: Visual Studio 2017 15.5.4 + Ncrunch 3.12.0.15.
Remco
#2 Posted : Thursday, January 18, 2018 11:09:57 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,179

Thanks: 688 times
Was thanked: 827 time(s) in 787 post(s)
Hi, thanks for sharing this problem.

On following these instructions, the MissingMethodException doesn't seem to appear for me. There must be something different about the assembly referencing behaviour in your environment.

When you enable the 'Pre-load all assembly references' setting, NCrunch will always load all referenced assemblies into the test environment before it invokes the tests. This gives stricter control over the assembly referencing process, as the normal loading of assemblies is heavily reliant on implicit logic dependent upon a range of factors (such as the contents of the GAC, etc).

If you're still seeing this in your small sample solution, would you mind submitting a bug report after it happens, then another report after enabling the 'Pre-load all assembly references' setting? I should be able to compare the logs to try and identify the problem.
MarcinG
#3 Posted : Thursday, January 18, 2018 11:32:29 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/18/2018(UTC)
Posts: 2
Location: Poland

Thanks: 1 times
I've just submitted the reports on yours contact form - our company firewall blocked sending the report directly from ncrunch. I Hope you'll find the reports :)
Remco
#4 Posted : Thursday, January 18, 2018 11:17:40 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,179

Thanks: 688 times
Was thanked: 827 time(s) in 787 post(s)
Thanks for sending through the logs.

It looks like this is a known issue in .NET itself, see https://github.com/dotnet/standard/issues/476.

Although the problem only appears for you under NCrunch, this doesn't seem to be caused by NCrunch itself. The occurrence of the problem is determined by the order in which the DLLs are loaded by the CLR.

It looks like many people are getting around this with a binding redirection. Otherwise, the pre-load assembly references setting should be an effective solution in your situation.
1 user thanked Remco for this useful post.
MarcinG on 1/19/2018(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.034 seconds.