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

Notification

Icon
Error

System.Xml.ReaderWriter not found when running ASP.NET Core projects in NCrunch
alastairs
#1 Posted : Wednesday, May 17, 2017 8:03:10 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 36
Location: Cambridge, UK

Thanks: 12 times
Was thanked: 2 time(s) in 2 post(s)
I'm using Visual Studio 2017 Professional, NCrunch 3.7.0.7. When I run my ASP.NET Core project in other test runners (e.g. ReSharper's, Visual Studio's), the tests run successfully. In NCrunch, however, the test run fails with the following exception:

Code:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
at Microsoft.AspNetCore.Builder.JwtBearerOptions..ctor()
at WebApi.Authentication.AuthenticationBuilder.Configure(IApplicationBuilder app) in \src\WebApi\Authentication\AuthenticationBuilder.cs:line 44
at WebApi.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IAccountsStore accountsStore) in \src\WebApi\Startup.cs:line 96
at CH360.Platform.WebApi.Tests.TestStartup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IAccountsStore accountsStore) in \test\WebApi.Tests\WebApiHost.cs:line 72
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder)
at WebApi.Tests.WebApiHost..ctor() in \test\WebApi.Tests\WebApiHost.cs:line 22
at WebApi.Tests.WebApiSpecialHeaderAuthorizationFacts..ctor() in \test\WebApi.Tests\WebApiSpecialHeaderAuthorizationFacts.cs:line 18


The failing tests reference Microsoft.AspNetCore.TestHost v1.1.1 to run the ASP.NET MVC Core application in memory. A bit of digging indicates that `System.Xml.ReaderWriter` is part of the .NET Standard Library and doesn't need to be referenced directly. I've tried using CopyReferencedAssemblies in NCrunch Configuration to no avail.
Remco
#2 Posted : Wednesday, May 17, 2017 10:20:13 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 606 times
Was thanked: 697 time(s) in 667 post(s)
References of this sort are usually resolved implicitly by the Core CLR using the .deps file. My first thought is that perhaps this is trying to resolve the wrong version of this assembly for some reason.

Are you able to build a sample project that can reproduce this issue and you can share with me? Dependency resolution issues just seem to get more and more complicated with each version of .NET, and unfortunately I don't think I can easily narrow this problem down with targeted questioning :(
alastairs
#3 Posted : Friday, May 19, 2017 9:23:21 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 36
Location: Cambridge, UK

Thanks: 12 times
Was thanked: 2 time(s) in 2 post(s)
I'll try to create a reproduction, but I've only seen this behaviour with this one project of many that we have... Would providing the .deps file be useful? The thing that puzzles me most is why the same behaviour isn't present in other test runners.
Remco
#4 Posted : Friday, May 19, 2017 12:18:30 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 606 times
Was thanked: 697 time(s) in 667 post(s)
Thanks. Unfortunately I don't see it really being possible to troubleshoot this problem without a buildable project/solution that can reproduce it. I don't think this will be a simple problem to pin down, and the .deps file is only a small piece of the puzzle here. It's my experience that other test runners are piped through VSTest's environment, which has its own limitations and a very different internal architecture to NCrunch. I only have experience with the internals of one .NET Core capable test runner (NCrunch).
1 user thanked Remco for this useful post.
alastairs on 5/19/2017(UTC)
alastairs
#5 Posted : Friday, May 19, 2017 3:59:54 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 36
Location: Cambridge, UK

Thanks: 12 times
Was thanked: 2 time(s) in 2 post(s)
Ok, thanks Remco. I'll see if I can spot any obvious differences in the project files and I'll try to put together a reproduction.
alastairs
#6 Posted : Friday, May 19, 2017 4:18:34 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2011(UTC)
Posts: 36
Location: Cambridge, UK

Thanks: 12 times
Was thanked: 2 time(s) in 2 post(s)
I think I've found it - another project in the solution is explicitly referencing System.Xml.ReaderWriter at a lower version than the one expected by the ASP.NET Core project above. Thanks for being my rubber duck :)
Remco
#7 Posted : Friday, May 19, 2017 11:06:39 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 606 times
Was thanked: 697 time(s) in 667 post(s)
alastairs;10419 wrote:
I think I've found it - another project in the solution is explicitly referencing System.Xml.ReaderWriter at a lower version than the one expected by the ASP.NET Core project above. Thanks for being my rubber duck :)


Great find! Thanks for letting me know :)
Users browsing this topic
Guest (2)
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.