<shortversion>Why is the order of referenced DLLs important when
compiling C# code. A DLL with 'internal' types appearing ahead of a DLL
with the same 'public' types will cause the build to
fail.......</shortversion>
I have a Solution TEST.SLN with multiple projects (that reference each
other - but in a tree, no 'self-referencing').
ProjectA references DataAccess.DLL, and ALSO references Helper.DLL
Helper.DLL is ILMerged output of an entirely seperate Solution which
_also_ references DataAccess.DLL but ILMerge was setup to make all
non-primary classes *internal*.
When compiling from within VS03, there is no problem.
When NAnt does the build (via SLiNgshot/csc), it fails with
----
ProjectA.cs(52,4): error CS0122: 'DataAccess.MyConnection' is
inaccessible due to its protection level
ProjectA.cs(54,20): error CS0246: The type or namespace name
'connection' could not be found (are you missing a using directive or
an assembly reference?)
----
But I *know* it's internal (and therefore inaccessible). It's supposed
to be - the public type that i want the compiler to link to is in
another reference in the list supplied to it!
<examples>Stripping away VS/NAnt/etc and just using the C# compiler
csc.exe...
csc /target:library /out:"ProjectA.dll" /r:"DataAccess.dll"
/r:"Helper.dll" ProjectA.cs
WORKS - presumably the compiler finds the PUBLIC DataAccess in
DataAccess.DLL and can therefore link ProjectA.cs references to that
type
csc /target:library /out:"ProjectA.dll" /r:"Helper.dll"
/r:"DataAccess.dll" ProjectA.cs
FAILS - the compiler seems to find the INTERNAL DataAccess classes in
Helper.DLL and GIVES UP compiling, rather than look for a PUBLIC
implementation of those types in any of the other references.
</examples>
Question 1: _why_ doesn't the compiler try harder to resolve the type,
rather than giving up when it finds an internal declaration of the
type?
Question 2: presumably the compilation only works in VS03 because _by
chance_ ordering of the references?
Question 3: is there a way to make ILMerge obfuscate the types it
internalizes? (yes, i know it can obfuscate duplicate type names, but
this isn't quite the same situation)
Question 4: is there a way to force the order of the reference
parameters in SLiNgshot or the NAnt csc Task? (OK, I have already
downloaded the NAnt source to look into this, but hoping someone's
already done this)
Thanks in advance for any advice/assistance
Craig
www.conceptdevelopment.net