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.

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.

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.

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.

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.

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.

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!

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.

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.

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.