> For some reason (perhaps related to the use of ilmerge in NHibernate
> 3.1), there is now an exception being thrown in the relinq code.
re-linq contains the following code:
// typeof (object).Assembly.GetName() will throw an exception in medium trust.
// Therefore, scan references to detect the referenced framework version.
var mscorlibReference =
Assembly.GetExecutingAssembly().GetReferencedAssemblies().Single (name
=> name.Name == "mscorlib");
var referencedFrameworkVersion = mscorlibReference.Version;
This code is safe because the re-linq assembly (returned by
Assembly.GetExecutingAssembly()) will always contain exactly one
reference to mscorlib. This is true even when using a .NET 3.5 build
from .NET 4.0. The only way to break it is to somehow "customize" the
re-linq assembly so that it has two references to mscorlib at the same
time.
We've just tried out using the current merged NHibernate/re-linq (via
nhforge), and we couldn't reproduce the reported exceptions, not even
from MSTest. The merged DLL has only one reference to mscorlib. I can
only imagine that the person who originally reported the issue has
some custom build, post-build-step, instrumentation, or similar that
causes the duplicate references.
I've nonetheless added a feature request to our JIRA:
"https://www.re-motion.org/jira/browse/RM-3832". The code is easy for
us to replace, so you can expect build 1.13.100 of re-linq (to be
released on Friday) to contain the change.
I'd still recommend double-checking the setup of the person who
reported the problem.
> I tried to file an issue, but I don't have an account.
On our JIRA Dashboard, you can click "register here" to get an account
so you can file issues.
Regards,
Fabian
> I share your suspicions that there's some edge case at work; just to
> rule out one possibility - we don't have any kind of special build/
> postbuild setup going on. Our MSBuild and Team Build (test) setups are
> vanilla.
That's really strange. Maybe the code calling GetExecutingAssembly
gets inlined by the JIT compiler to some place that references two
mscorlibs? Never mind, though because...
> Though I see from the Jira issue that it is probably too late :)
> perhaps the way to avoid further confusion by selecting the First() is
> to use Max(a => a.Version) or something similar.
... I've found a better alternative to the code in question and have
already adapted it.
> If we track down any more information I'll post it here. Thanks again!
Although the code has already been removed, I'd be very interested if
you find out the reason for the duplicate references.
Regards,
Fabian