Re: Adding references: the details



_DS wrote:

> On Tue, 17 Jan 2006 01:42:55 -0800, "Frans Bouma [C# MVP]"
> <perseus.usenetNOSPAM@xxxxxxxxx> wrote:
>
> > _DS wrote:
> >
> >> Add existing project to the solution, then add a ref to
> 'Project'. >>
> >> 1: I'd like to find out what the latter method is doing.
> >> I'm assuming that it makes sure that debug exe gets matched to
> >> debug DLL, etc. What else is going on? (I couldn't locate
> much >> info in MSDN)
>
> > the second option adds a reference to project\obj\assembly.dll for
> > compilation and in the csproj file it adds a reference to the
> > project instead of the dll, that's it.
>
> It could ref either the debug or the release version. Since the
> project was now being referenced as a whole, I assumed that the
> correct match for given compilation mode (debug vs release ) would be
> chosen. Sounds like the answer is No. So which DLL would be chosen?

the one belonging to the current action. So if you build a debug
build, the debug version is referenced. THough that doesn't matter. In
debug or release, the assembly names are the same, which is what
matters.

> >> I hope that was understandable. Any way to simplify that, or must
> >> the top solution go through the add-to-project and
> add-ref-to-project >> for every sub-sub-sub-assembly that's
> referenced?
> >
> > That shouldn't be necessary. My exe references assembly A, which
> > references assembly B and B is placed inside the bin folder of the
> > exe without a problem, automatically.
>
> Then something is not right. The Exe is never referring to B
> directly.

No of course it isn't doing that. but B is ending up in the bin\debug
or bin\release folders and when you try to run the exe it will run.

If the exe is referring in code to types in B, B has to be referenced
manually.

> The Exe refers only to A, which in turn refers to B.
> You'd think that compile references would handle this. But though A
> and B are compilable on their own, adding assembly A to the exe file
> will generate an error message about unresolved items in B.
>
> What could cause or fix that?

Please remember that 'an error message' is a statement which doesn't
help, please state the error message you get, I'll now assume what
happens and I think it's because you have a base type in B, you derive
a class from that in A and you use that type in the .exe, correct? The
..exe then needs a reference to B if you in your code use public
methods/properties from the type which are actually defined in the base
class in B. This is logical, as the methods/properties aren't known in
A, they're defined in B.

This indeed isn't done automatically, the error description suggests
what to do to fix it.

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
.



Relevant Pages

  • Re: Adding references: the details
    ... >> I'm assuming that it makes sure that debug exe gets matched to ... >> debug DLL, etc. ... >compilation and in the csproj file it adds a reference to the project ... >> Just add assembly B to A's solution, then set a reference to B. ...
    (microsoft.public.dotnet.languages.csharp)
  • Debug problem
    ... What I find particularly odd is that the exe created by the build seems to ... Debug Problems ... Then I got an idea and moved the exe to another folder on the ... the laptop. ...
    (microsoft.public.vstudio.general)
  • Re: .exe debug without sources from Visual Studio 2005
    ... >running WM 2003 SE using eVC 4.0 debugger with no problem. ... >that I want to debug that exe on another target device running Windows ... debugging unless the platform specified in the IDE matches the actual ...
    (microsoft.public.windowsce.embedded)
  • Re: properly disposing of filestream
    ... Try to use the release version of the EXE for the one app, and debug from VS the another instance. ... "The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it" Michelangelo ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Debug inside a library
    ... You can only debug a process from one debugger as far as I know. ... EXE project, right-click on the solution in solution explorer, and click Add ... and select the DLL project. ... Make sure you add the reference in the EXE ...
    (microsoft.public.dotnet.languages.vb)