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

Notification

Icon
Error

.net 4.7.1 support
Magbr
#1 Posted : Thursday, November 16, 2017 8:25:44 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
Hi, we're also waiting for .net 4.7.1 support. I tried downloading 3.12.0.4 but there's no support for it yet.

We need .net 4.7.1 so we can share code between the .net framework and .net core 2.0.

And I would very much like to be able to run tests again asap.
Remco
#2 Posted : Thursday, November 16, 2017 10:36:38 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
1 user thanked Remco for this useful post.
Magbr on 1/8/2018(UTC)
Magbr
#3 Posted : Monday, January 8, 2018 2:01:04 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
Hi Remco, thanks for the fix. Unfortunately I was stupid and gave in to the never ending VS update notifications.

Now I can't get my assemblies to build again in Ncrunch, builds fine in VS. I tried a NCrunch repair without luck.

It seems like it's the same exception as before.

An error occurred while analysing this project after it was built: System.BadImageFormatException: Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
File name: 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\Facades\System.Runtime.dll' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
File name: 'file:///C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\Facades\System.Runtime.dll' ---> System.BadImageFormatException: Cannot load a reference assembly for execution.

I've been unable to downgrade visual studio(with restore point).

Please help.
Remco
#4 Posted : Monday, January 8, 2018 10:31:38 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Hi,

Support for .NET 4.7.1 went out officially with the 3.12 release. To my knowledge, it seems to be stable. I think the problem you're experiencing is something entirely different.

Can you make sure you're running on the latest 3.12 release from the download page, and try deleting the contents of your project 'obj' and 'bin' directories while VS is closed?
Magbr
#5 Posted : Tuesday, January 9, 2018 10:55:35 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
Upgraded from 3.12.0.13 to 3.12.0.15 (uninstall, install) and deleted the obj and bin folders from the test project throwing a fit.

It didn't do anything unfortunately...
Remco
#6 Posted : Tuesday, January 9, 2018 11:10:40 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Where do you see this error message? Does it happen on test execution or discovery?

Is this something you can reproduce in a small sample project?

Any chance you could submit a bug report after it's happened to you? I might be able to extract more information from the log in the report.
1 user thanked Remco for this useful post.
Magbr on 1/9/2018(UTC)
Magbr
#7 Posted : Tuesday, January 9, 2018 11:39:16 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
Hi wow, thanks for getting back to me this fast! I'm not quite sure, but this is the full error message;

An error occurred while analysing this project after it was built: System.BadImageFormatException: Could not load file or assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
File name: 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\Facades\System.Runtime.dll' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
File name: 'file:///C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\Facades\System.Runtime.dll' ---> System.BadImageFormatException: Cannot load a reference assembly for execution.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at nCrunch.Common.CustomAssemblyResolver.ResolveAssembly(ParsedAssemblyName parsedAssemblyName)
at nCrunch.Common.CustomAssemblyResolver.(Object , ResolveEventArgs )
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)


at Xunit.Sdk.TestFrameworkProxy.GetTestFrameworkType(IAssemblyInfo testAssembly, IMessageSink diagnosticMessageSink)
at Xunit.Sdk.TestFrameworkProxy..ctor(Object testAssemblyObject, Object sourceInformationProviderObject, Object diagnosticMessageSinkObject) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\TestFrameworkProxy.cs:line 23$$RethrowMarker$$ at ExceptionExtensions.RethrowWithNoStackTraceLoss(Exception ex)
at Xunit.AppDomainManager_NoAppDomain.CreateObject[TObject](AssemblyName assemblyName, String typeName, Object[] args)
at Xunit.Xunit2Discoverer..ctor(AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, String assemblyFileName, String xunitExecutionAssemblyPath, String configFileName, Boolean shadowCopy, String shadowCopyFolder, IMessageSink diagnosticMessageSink, Boolean verifyAssembliesOnDisk)
at nCrunch.Module.XUnit2.Integration.XUnitTestFrameworkContainer.GetDynamicFramework(FilePath assemblyFilePath, DirectoryPath workingDirectory)
at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.<>c__DisplayClass2_0.<FindFrameworkTestsInAssembly>b__1()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Common.PerformanceTracking.PerfTracker.TryTrackActivity(String name, Action activity)
at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.TestFinder..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)

I just submitted a bug report. I can try to make a repro if that doesn't help. Thanks so much for looking into this! ':)



Remco
#8 Posted : Tuesday, January 9, 2018 10:33:46 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Thanks for these extra details.

The root of the problem here is that NCrunch is attempting to load System.Runtime from the Facades directory. It's doing this because the build system reports the project as being built against the facade of System.Runtime, while the runtime probably expects this to be loaded from a different location (i.e. the GAC). So your project is being built against one assembly, and the runtime expects to run it against another. Up until now, we've only seen this kind of behaviour in .NET Core (which needs it for cross-platform support).

What doesn't make sense to me is why the runtime is requesting this assembly through NCrunch's assembly resolver. On my own machine, when I try to set up a basic little Xunit2 test project targeting .NET 4.7.1, I see NCrunch building the project against the Facade, but it won't try to load the Facade at runtime because the concrete version of this assembly is in the GAC (which should take precedence).

So I think we're looking at one of two possibilities:

1. You've managed to construct a test project in which the evaluation sequence of the Xunit code for the project somehow causes it to search for System.Runtime through the NCrunch assembly resolution process. Perhaps this is done through use of specialised structures or 3rd party Xunit plugins. It's a structure that I haven't managed to recreate myself.

2. Something is not right with your .NET 4.7.1 installation, and the runtime assemblies are not correctly loaded in the GAC or are otherwise not being correctly read from there by the .NET Runtime.

Are you, by chance, running a preview version of VS2017?
Magbr
#9 Posted : Wednesday, January 10, 2018 10:00:32 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
I'm not. Community 15.5.2.

I'll try to get it running on my laptop.

If that doesn't work I guess I'll have to do a clean start...

I'll get back to you!
Magbr
#10 Posted : Wednesday, January 10, 2018 10:30:40 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
I don't know if I was clear about it but what's weird is that everything ran just fine. I then updated my VS over night and the next morning none of the test projects were building/running..

So I'm pretty suspect about this being something related to your second suggestion.
Magbr
#11 Posted : Wednesday, January 10, 2018 3:28:42 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
So I tried the reinstall. Reinstalled the OS, Visual Studio and NCrunch.

Still no luck.

Just FYI I use AutoFixture and AutoNSubstitute for some unit tests. But I also use them in the projects that are building and running just fine.

Another weird thing is that the three test projects with the error are all Integration test projects.

Also don't know if you think the yellow warning icons on the references matter. It builds just fine in VS.
[img=https://gyazo.com/69e56bad854684834f1a188aa56ae216]Vs assembly reference warnings[/img]

Thoughts?
Remco
#12 Posted : Wednesday, January 10, 2018 10:51:33 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Thanks for the extra details. You mentioned that you'd tried to get this running on your laptop (which I assume is a different machine?), did it work there? I think right now we need to try and establish whether this problem is related to your environment, or whether it's solution specific.

If it's solution specific, I can probably analyse it quite quickly if you're able to get me a sample solution that can reproduce the problem. The sample I tried to put together with the information you gave me didn't seem to surface the issue, so if it's not environment related then it must be something I've missed. Are you able to have a go at reducing it to a small solution that you can share with me? You can upload it through the contact form.

The warning icons in VS are suspicious, though I don't personally know enough about how these work to say if they're related or not. I've seen VS do weird things with these icons.
1 user thanked Remco for this useful post.
Magbr on 1/15/2018(UTC)
Magbr
#13 Posted : Monday, January 15, 2018 11:42:32 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
I got to many other seemingly unrelated issues on that branch on my laptop(yes, it's a different computer). Boy are IDE's fragile..

It would surprise me if it was environment specific at this point as I did a fresh install of windows, vs and ncrunch.

Just started uploading a repro solution. It's kinda big, I thought it best to include the nugets just the way they are on my machine, in case that matters. 90MB, I don't know if you have a upload limit. If you do I'll remove the nuget packages and try to reupload.

Thanks!
Magbr
#14 Posted : Monday, January 15, 2018 11:45:41 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
It seems the big file version upload timed out.

I actually got a 404 when uploading the smaller sample, 13-14MB.

https://www.ncrunch.net/error/http404

Tell me if the upload went through or not. If not I can upload it to OneDrive and send you a link.
Remco
#15 Posted : Monday, January 15, 2018 10:18:37 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Magbr;11697 wrote:

Tell me if the upload went through or not. If not I can upload it to OneDrive and send you a link.


Doesn't look like it made it :( Including the Nugets is definitely helpful as it reduces the risk of me getting something wrong when calibrating the solution in my own environment. If you have a OneDrive or DropBox link, that would be really great. You can send the link through the contact form (it'll work this time) if you want to keep it private.
Magbr
#16 Posted : Tuesday, January 16, 2018 9:12:57 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
Just sent the link.

Btw what time zone are you in?
Remco
#17 Posted : Tuesday, January 16, 2018 10:04:58 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Thanks! I now have the test solution and it's producing the problem exactly as you've described.

The trigger for this seems to be the binding redirections in the app.config file. Even though they are targeting different versions of System.Runtime, somehow this seems to change the resolution sequence and cause the problem to surface.

We'll need to take a closer look at this before introducing a code-fix, but there is a workaround that should be able to get around this immediately.

Inside your project file, find the declaration for your App.config file, for example:

<None Include="App.config">
<SubType>Designer</SubType>
</None>

Make this condition on NCrunch not being resident, as such:

<None Include="App.config" Condition="'$(NCrunch)' != '1'">
<SubType>Designer</SubType>
</None>

This will exclude the config file from the NCrunch environment, allowing the assembly resolution to behave as though the binding redirect doesn't exist.

I'm in New Zealand (~GMT+12), though I don't typically work or sleep normal hours :)
Magbr
#18 Posted : Tuesday, January 16, 2018 10:14:12 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
I feel so stupid not having figured this out. I was messing around with the binding redirects, I just wasn't doing it in the right project(test project).

As an alternative workaround just simply removing the binding redirect from app.config works!

Thank you so much, Remco! :)

Also if you don't mind I'd hijack this thread for a feature suggestion.
I spend most of my time with the tests UI closing down tests in order to get to the tests I care about. If you could make a 'collapse all' feature like the solution explorer's you'd sure save me a lot of time!

Remco
#19 Posted : Tuesday, January 16, 2018 11:15:27 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 705 times
Was thanked: 878 time(s) in 835 post(s)
Magbr;11701 wrote:
I feel so stupid not having figured this out. I was messing around with the binding redirects, I just wasn't doing it in the right project(test project).

As an alternative workaround just simply removing the binding redirect from app.config works!


Great to hear! This always was the simplest solution :)


Magbr;11701 wrote:

Also if you don't mind I'd hijack this thread for a feature suggestion.
I spend most of my time with the tests UI closing down tests in order to get to the tests I care about. If you could make a 'collapse all' feature like the solution explorer's you'd sure save me a lot of time!


This is a common feature request. The reason it hasn't happened yet is the lack of toolbar space, but we're working on that. I'm fairly certain this is already captured on uservoice if you'd like to add your vote to it.
Magbr
#20 Posted : Tuesday, January 16, 2018 11:21:34 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/25/2016(UTC)
Posts: 17

Thanks: 4 times
Remco;11702 wrote:

This is a common feature request. The reason it hasn't happened yet is the lack of toolbar space, but we're working on that. I'm fairly certain this is already captured on uservoice if you'd like to add your vote to it.


I just did! Doesn't look like it's 'planned' though.
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.149 seconds.