PC Review


Reply
Thread Tools Rate Thread

csc /reference - order is important (why?) [1.1]

 
 
craigd
Guest
Posts: n/a
 
      14th Jun 2006
<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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference field by it's order John J. Microsoft Access 4 10th Feb 2009 05:29 PM
Reference Order DS Microsoft Access VBA Modules 3 3rd Oct 2008 02:21 PM
what's important, field name or its order? dindigul Microsoft Access External Data 3 28th Sep 2008 01:09 PM
how do i reference in alphabetical order =?Utf-8?B?ZGVicw==?= Microsoft Word Document Management 2 18th Nov 2005 05:33 PM
9600XT Pre-order: Best Buy is more important to ATI than their own online store customers? Bob ATI Video Cards 1 5th Dec 2003 02:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:47 AM.