473,414 Members | 1,677 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,414 software developers and data experts.

Inheritance and assembly references in multilayerd solution

I have one of those seemingly simple questions that evades/confuses me.
I've created an assembly with bass classes (classes meant to be inherited in
other assemblys). In a secondary assembly (my business layer) I created a
class which inherits from a base class in the first assembly....so far so
good.

If I create a third assembly (my UI layer) and add reference in it to the
business layer and I access a public variable in the business layer...and
that variable is from the bass class I get an error in the UI like

'<name>' is declared in project '<projectname1>', which is not referenced by
project '<projectname2>'

To resolve this I have to add a reference in the UI to the base class so the
UI assembly now has a reference to the base class *and* the inherited class.
My question is: Why? I wouldn't have expected to need a reference to the
base class.....I would think the UI wouldn't have to know anything about the
base class.
Oddly enough even though there is an error message and the UI assembly won't
compile (without a ref to the base class) intellitype still shows me all the
base class public members and interfaces that are in the inherited class.
Example:
=========================
Assembly A

Public Class MyAClass
Public var1 as string
End Class
==========================
Assembly B (which references A)
Public Class MyBClass: Inherits MyAClass
End Class
==========================
Assembly C (which references B)

B.MyBClass.var1

Error Message is:
"var1 is declared in project A.dll which is not referenced by project C.dll"

But even with error intellitype shows .var1

Thanks

Brad
Nov 20 '05 #1
2 2289
Brad,
To resolve this I have to add a reference in the UI to the base class so the UI assembly now has a reference to the base class *and* the inherited class. My question is: Why? I wouldn't have expected to need a reference to the
base class.....I would think the UI wouldn't have to know anything about the base class. Unfortunately its the way the references work, as best as I can tell the
inherited class does not include all the meta data of the base class
assembly (as it can change). Hence the need to reference both assemblies.

I think we could have more problems if the inherited class's assembly did
include all the meta data of the base class assembly, as we would definately
have code bloat & what happens when the base class assembly changes?

Hope this helps
Jay

"Brad" <no****@co.lane.or.us> wrote in message
news:O6**************@TK2MSFTNGP11.phx.gbl... I have one of those seemingly simple questions that evades/confuses me.
I've created an assembly with bass classes (classes meant to be inherited in other assemblys). In a secondary assembly (my business layer) I created a class which inherits from a base class in the first assembly....so far so
good.

If I create a third assembly (my UI layer) and add reference in it to the
business layer and I access a public variable in the business layer...and
that variable is from the bass class I get an error in the UI like

'<name>' is declared in project '<projectname1>', which is not referenced by project '<projectname2>'

To resolve this I have to add a reference in the UI to the base class so the UI assembly now has a reference to the base class *and* the inherited class. My question is: Why? I wouldn't have expected to need a reference to the
base class.....I would think the UI wouldn't have to know anything about the base class.
Oddly enough even though there is an error message and the UI assembly won't compile (without a ref to the base class) intellitype still shows me all the base class public members and interfaces that are in the inherited class.
Example:
=========================
Assembly A

Public Class MyAClass
Public var1 as string
End Class
==========================
Assembly B (which references A)
Public Class MyBClass: Inherits MyAClass
End Class
==========================
Assembly C (which references B)

B.MyBClass.var1

Error Message is:
"var1 is declared in project A.dll which is not referenced by project C.dll"
But even with error intellitype shows .var1

Thanks

Brad

Nov 20 '05 #2
Hi Brad,

Every managed module contains metadata tables. There are two main types of
tables: tables that describe the types and members defined in your source
code and tables that describe the types and members referenced by your
source code.

IntelliSense is one of the functions of metadata tables.
Visual Studio .NET uses metadata to help you write code. Its IntelliSense
feature
parses metadata to tell you what methods a type offers and what parameters
that
method expects.

AssemblyRef metadata table is one of metadata tables.

AssemblyRef
Contains one entry for each assembly referenced by the module. Each entry
includes the information necessary to bind to the assembly: the assembly¡¯s
name (without
path and extension), version number, culture, and public key token
(normally a small hash value, generated from the publisher¡¯s public key,
identifying the referenced
assembly¡¯s publisher). Each entry also contains some flags and a hash
value. This hash value was intended to be a checksum of the referenced
assembly¡¯s bits. The CLR completely ignores this hash value and will
probably continue to do so in the future.

You may try to observe the metadata tables of the three assemblies(A,B and
C, you mention in your post) using the tool ildasm.
It can be found in the path below.
<Microsoft Visual Studio .NET 2003>\SDK\v1.1\Bin\ildasm.exe
Viewing Assembly Contents
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconusingildasmexetoviewassemblycontents.asp

For detailed information, you may refer to the book witten by Jeffrey
Richter.
Applied Microsoft .NET Framework Programming
Microsoft is providing this information of recommendation of the book as a
convenience to you with no warranties.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Brad" <no****@co.lane.or.us>
Subject: Inheritance and assembly references in multilayerd solution
Date: Wed, 15 Oct 2003 15:42:37 -0700
Lines: 51
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.0
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Message-ID: <O6**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: risxlr5.ris.lane.or.us 199.79.46.126
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:147112
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

I have one of those seemingly simple questions that evades/confuses me.
I've created an assembly with bass classes (classes meant to be inherited inother assemblys). In a secondary assembly (my business layer) I created a
class which inherits from a base class in the first assembly....so far so
good.

If I create a third assembly (my UI layer) and add reference in it to the
business layer and I access a public variable in the business layer...and
that variable is from the bass class I get an error in the UI like

'<name>' is declared in project '<projectname1>', which is not referenced byproject '<projectname2>'

To resolve this I have to add a reference in the UI to the base class so theUI assembly now has a reference to the base class *and* the inherited class.My question is: Why? I wouldn't have expected to need a reference to the
base class.....I would think the UI wouldn't have to know anything about thebase class.
Oddly enough even though there is an error message and the UI assembly won'tcompile (without a ref to the base class) intellitype still shows me all thebase class public members and interfaces that are in the inherited class.
Example:
=========================
Assembly A

Public Class MyAClass
Public var1 as string
End Class
==========================
Assembly B (which references A)
Public Class MyBClass: Inherits MyAClass
End Class
==========================
Assembly C (which references B)

B.MyBClass.var1

Error Message is:
"var1 is declared in project A.dll which is not referenced by project C.dll"
But even with error intellitype shows .var1

Thanks

Brad


Nov 20 '05 #3

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

Similar topics

1
by: Zachary Hartnett | last post by:
I was trying to write a routine this morning that would open a given assembly, walk the inheritance tree of classes in the assembly, and provide a list of classes in the assembly that inherit from...
4
by: Tiraman | last post by:
Hi , Problem description : I have 2 assemblies (A.dll And B.dll) . They are both under the GAC and they are both using the functions of each other . Each time that I m doing a change in...
2
by: john | last post by:
Maybe I haven't had that "a-ha" moment yet, but I think the new approach to web projects is a step in the wrong direction. My main beef is that control over the assembly generation process has...
5
by: rkozlin | last post by:
Running into an issue where the compiler will throw an error... "The type '<BaseClass>' is defined in an assembly that is not referenced. You must add a reference to assembly '<BaseClass>'." ...
9
by: MSDNAndi | last post by:
Hi, I have the following problem with VS 2005 (Professional) and C# 2.0 I will use assembly and namespace synonymously here. I have a class in namespace InheritClass inherit from a baseclass...
3
by: Richard Lewis Haggard | last post by:
I'm getting an error that should be easy but I don't understand the info structure well enough to know what's going wrong. I've been slowly adding classes and projects to a solution for a while....
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
1
by: Richard Lewis Haggard | last post by:
I'm having a problem with what appears to be some sort of confusion with references. I have a single solution with a dozen projects which has been working quite nicely for a while. The references...
4
by: BillE | last post by:
Does a subclass have to import namespaces which were already imported by the superclass? I have a base class which imports the System.Data.SQLClient namespace to use the dataset member. When...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.