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

Notification

Icon
Error

When/Why is "Pre-load all assembly references into test environment" required
damageboy
#1 Posted : Monday, August 25, 2014 10:06:33 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/21/2014(UTC)
Posts: 9
Location: Israel

Was thanked: 1 time(s) in 1 post(s)
Hi,
In my 70+ project solution I have a specific "chain" of projects that I can't get to run tests without turning on
the "Pre-load all assembly references into test environment" option for the top-level project.
The chain of projects goes like this:
X.Tests (Project) -> X (Project) -> Compression.MixedMode.dll (Static Reference)

X.Tests is the unit-test projects for X
X is one on my projects which depends on:
Compression.MixedMode.dll - a mixed mode binary that has .NET MSIL code mixed with native x86/x64

When I started playing around with V2, this project (X.Tests consistently failed to run, complaining that it can't find Compression.MixedMode.dll while running the tests (Compilation runs fine).

I tried increasing NCrunch's verbosity, but except for seeing that NCrunch isn't picking up the dependency on Compression.MixedMode.dll (since NCrunch spits out dependencies when running tests in detailed mode).

I can't understand why it's not picking up the dependency normally, since it's "just" another .NET binary, as far as NCrunch SHOULD be bothered about it.
It might not be related to it being a mixed mode library, but I think that's highly unlikely since it's the only mixed mode library in the project on the one hand, and it's the only project that seems to be affected by it.

Any ideas?
Remco
#2 Posted : Monday, August 25, 2014 10:36:04 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi,

It can be difficult to tell why the CLR would have trouble loading the mixed mode assembly at run-time. My first thought is that the CLR may be behaving very differently when loading this assembly due to it being structurally different to a normal .NET assembly.

When the pre-load assembly references setting is disabled, NCrunch will attempt to direct the CLR to a test environment's dependencies passively by hooking events into the test application domain and serving up the assembly when the CLR fails to find it. The CLR almost always fails to find assemblies for the NCrunch test environment in its initial pass - this is by design, as the only reliable point at which NCrunch can intercept the request for an assembly is after the CLR has completed its normal scanning logic (which involves the GAC, the current directory, etc).

When the pre-load assembly references setting is enabled, NCrunch will load all the dependencies of a test environment into the application domain before it starts executing tests. Because it can tell the CLR exactly where to find the assemblies, there is never any ambiguity around which assemblies are loaded, nor is there any reliance on the CLR's implicit assembly loading logic.

Normally the need to turn on pre-loading of assembly references stems from the need to prevent the CLR from loading the wrong assembly. This can happen in certain situations where the 'copy referenced assemblies to workspace' is enabled and different versions of the same assembly are being used in the solution.

The only situation I can think of where pre-loading of assembly references actually ALLOWS the CLR to find an assembly that passive searching wouldn't normally find is if the CLR were behaving strangely around the resolution of assemblies, and wasn't correctly invoking the resolution events before declaring that the assembly couldn't be found. If this is indeed the case, then there is no way for NCrunch to passively serve up this dependency and switching on the pre-load assembly references setting will be the only way that this problem can be solved.

It might be possible to get more information about this by turning on Fusion logging and taking a look a the fusion logs. Often these logs can be quite revealing around assembly reference issues.
damageboy
#3 Posted : Monday, August 25, 2014 5:08:19 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/21/2014(UTC)
Posts: 9
Location: Israel

Was thanked: 1 time(s) in 1 post(s)
Hi Remco, and again thanks for the thoughtful reply...
I wouldn't mind diving into it at some point, but it's something I'll probably postpone till I'm really really bored.
1 user thanked damageboy for this useful post.
Remco on 8/25/2014(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.031 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download