473,385 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Adding references: the details

_DS
The two obvious methods for ref'ing assemblies are:

Add a reference and 'Browse' for the actual DLL

OR

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)

2: This method induces a couple glitches: If assembly A refs
assembly B, then the project for assembly A works as expected:
Just add assembly B to A's solution, then set a reference to B.

Now what about the final exe that uses assembly A: Add A to
the exe's solution, then set a reference to A. You'd expect that
B would be automatically ref'd by A's project. No such luck. The
build generates an error as if A can no longer find assebly B.

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?

Jan 17 '06 #1
3 1974
_DS wrote:
The two obvious methods for ref'ing assemblies are:

Add a reference and 'Browse' for the actual DLL

OR

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 doesn't matter if you reference the debug or release build @
compilation time, as long as an assembly with the same assembly version
is available at runtime when the application is deployed.
2: This method induces a couple glitches: If assembly A refs
assembly B, then the project for assembly A works as expected:
Just add assembly B to A's solution, then set a reference to B.

Now what about the final exe that uses assembly A: Add A to
the exe's solution, then set a reference to A. You'd expect that
B would be automatically ref'd by A's project. No such luck. The
build generates an error as if A can no longer find assebly B.
what does 'add A to the exe's solution mean, adding the project to the
solution or adding a reference to the compiled assembly?
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.

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#)
------------------------------------------------------------------------
Jan 17 '06 #2
_DS
On Tue, 17 Jan 2006 01:42:55 -0800, "Frans Bouma [C# MVP]"
<pe******************@xs4all.nl> 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?
It doesn't matter if you reference the debug or release build @
compilation time, as long as an assembly with the same assembly version
is available at runtime when the application is deployed.

2: This method induces a couple glitches: If assembly A refs
assembly B, then the project for assembly A works as expected:
Just add assembly B to A's solution, then set a reference to B.

Now what about the final exe that uses assembly A: Add A to
the exe's solution, then set a reference to A. You'd expect that
B would be automatically ref'd by A's project. No such luck. The
build generates an error as if A can no longer find assebly B.


what does 'add A to the exe's solution mean, adding the project to the
solution or adding a reference to the compiled assembly?


Add A's project to the Exe's project, then set a reference to A.
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. 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?

Jan 18 '06 #3
_DS wrote:
On Tue, 17 Jan 2006 01:42:55 -0800, "Frans Bouma [C# MVP]"
<pe******************@xs4all.nl> 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#)
------------------------------------------------------------------------
Jan 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark D. Anderson | last post by:
About a month ago Richard Cornford did an interesting analysis of a memory leak in jscript (internet explorer) when there are "circular" references between DOM objects and (real) jscript objects:...
2
by: MLH | last post by:
A97 topic. Opening a new thread related to some other discussions - > > > just to make sure < < < that installing an OCX or adding an mdb using references other than the BASIC-3 that I use...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
0
by: MIGUEL | last post by:
Hi all! Be patient because what I'm going to explain all of you it's more than very strange. I've developed a webservice project that contains two classes. One of them is going to act as a...
3
by: MIGUEL | last post by:
Hi all, I'm quite lost with how adding web references to a project creates proxy classes. I've developed a web service with two classes inside and that contains three references to three...
5
by: Michael Russell | last post by:
Hi all, Using C#, I've created a simple wrapper class for using Excel. I have Office Pro 2003 installed on my devel machine. The wrapper class works great, reading and writing to/from Excel. ...
9
by: igor.kulkin | last post by:
References is a relatively basic feature of C++ language. It might be a good thing to think of references as aliases to the variables. However it's good to think of references this way when you...
3
by: Shestine | last post by:
I am trying to add a column to a current table, with data in it. I am only learning, and i have no idea how to change this to make it work. Here is the script I have right now it, but what it does is...
6
by: alun65 | last post by:
I'm having trouble programmatically adding a user control and then setting some of it's server controls. I add the user control to the code behind and add it to a placeholder: protected void...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.