473,786 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2308
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******** ******@TK2MSFTN GP11.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/cpconusingildas mexetoviewassem blycontents.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.publi c.dotnet.langua ges.vb
NNTP-Posting-Host: risxlr5.ris.lan e.or.us 199.79.46.126
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP11.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:147112
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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
2794
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 DataSet. Here is a snippet from the routine I came up with: ------------------------------------------------------------ openFileDialog.ShowDialog(); Assembly assembly = Assembly.LoadFile(openFileDialog.FileName);
4
1224
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 one of them I need to change the
2
1883
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 been taken away from us! I also don't agree with the logic behind a web site not having a project file, but I'll save that for another thread! Here's our scenario: We have a web project that runs in a non-managed sharepoint directory. The web...
5
1440
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>'." .... when using a derived class where the base class and the derived class are compiled into separate assemblies. In this case we are attempting to reference the derived class in a project and had assumed that the base class assembly would...
9
2964
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 in namespace BaseClass. Then I have a class in namespace InheritClassUser that uses the class in namespace InheritClass. The references/using are from InheritClass to BaseClass and from
3
2561
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. There's a single test exe and a number of of# library classes. I needed to move two of the projects down one directory from their original position and did so my making the appropriate directory, copying the source to that directory, deleting the...
3
4413
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 really understand how this could be an issue. The assemblies that the system is complaining about are ones that we build here and we're not changing version numbers on anything. The errors come and go with no apparent rhyme or reason. We do not...
1
3181
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 between projects in the solution were established through project references, not by browsing to an assembly DLL. All of the projects are strongly named and use key files. Each project's AssemblyInfo.cs specifies the assembly version, where the...
4
1759
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 I inherit this base class, the subclass must also import the System.Data.SQLClient namespace to use its members. I thought that a subclass would not have to re-import namespaces which were
0
9496
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9961
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.