473,473 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Limit a class library or assembly references to specific projects?

Can a project or assembly limit the projects that may reference it?
For example, I have a legacy project used by a data layer project. I
don't want the object model project to be able to directly access the
legacy project. The object model or business logic project should only
be allowed to reference the data layer project.

Thanks,
Ché

Nov 7 '06 #1
2 2155
Any assembly can use any public type of other assemblies. There is no way of
restricting this. If a type is public it can be used. However access to
internal types is limited only withing the assembly itself.
..NET 2.0 extends their visiblity by introducing *friend assemblies*, so the
internal types and members are visible inside the assembly and in all
assemblies that the declaring assembly define as *friends*. So there is
probably your solution. Declare all the types (or at least the ones that you
don't want to be shared with everybody) as internal and let the legacy
assembly declare the datalayer as *firend*. The downside of this that the
datalayer will see everything even types and members that are internal
implementation.

For declaring *friend assemblies* look at MSDN
http://msdn2.microsoft.com/en-us/library/0tke9fxk.aspx

Read carefully because there are some requirements to use that feature; they
even can make it inaplicable with your project. Keep in mind also that this
feature is not available in .NET 1.x
--
HTH
Stoitcho Goutsev (100)

<Ch**********@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Can a project or assembly limit the projects that may reference it?
For example, I have a legacy project used by a data layer project. I
don't want the object model project to be able to directly access the
legacy project. The object model or business logic project should only
be allowed to reference the data layer project.

Thanks,
Ché
Nov 8 '06 #2
Thank you very much... I appreciate your help. This should keep a
clear division and keep other developers from ruining the integrity of
a project by crossing bussiness logic with data layer code.

On Nov 8, 10:16 am, "Stoitcho Goutsev \(100\)" <1...@100.comwrote:
Any assembly can use any public type of other assemblies. There is no wayof
restricting this. If a type is public it can be used. However access to
internal types is limited only withing the assembly itself.
.NET 2.0 extends their visiblity by introducing *friend assemblies*, so the
internal types and members are visible inside the assembly and in all
assemblies that the declaring assembly define as *friends*. So there is
probably your solution. Declare all the types (or at least the ones that you
don't want to be shared with everybody) as internal and let the legacy
assembly declare the datalayer as *firend*. The downside of this that the
datalayer will see everything even types and members that are internal
implementation.

For declaring *friend assemblies* look at MSDNhttp://msdn2.microsoft.com/en-us/library/0tke9fxk.aspx

Read carefully because there are some requirements to use that feature; they
even can make it inaplicable with your project. Keep in mind also that this
feature is not available in .NET 1.x

--
HTH
Stoitcho Goutsev (100)

<Che.Gonza...@gmail.comwrote in messagenews:11*********************@k70g2000cwa.go oglegroups.com...
Can a project or assembly limit the projects that may reference it?
For example, I have a legacy project used by a data layer project. I
don't want the object model project to be able to directly access the
legacy project. The object model or business logic project should only
be allowed to reference the data layer project.

Thanks,
Ché
Nov 8 '06 #3

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

Similar topics

5
by: Daniel Bass | last post by:
..Net is great for modulerising libraries, so that all you need do to access a DLL, is simply call Add Reference and wallah, it's as though the library were written in your project. But what...
11
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
0
by: Learning SQL Server | last post by:
I dont think I'm doing something right here or maybe I am misunderstanding the concept. Hope someone can help. I have a solution with 5 projects. Each one builds into its own class library. They...
8
by: Brett Romero | last post by:
I have this situation: myEXE <needs< DerivedClass <which needs< BaseClass Meaning, myEXE is using a type defined in DerivedClass, which inherits from BaseClass. I include a reference to...
3
by: Med | last post by:
Hi, I use Visual C# Express 2005 and Visual Web Developer Express 2005. In my Visual C# Express 2005 Solution, I have following two class library projects: _ DataAccess (Namespace name:...
4
by: Alan Mailer | last post by:
Again, I'm new to VB.net and there is something I need help with: Like (I assume) many of us, over time I want to be able to create some VB.net classes that I might want to use in more than one...
3
by: kimiraikkonen | last post by:
Hi there, I want to begin understanding how class libraries are written under VB.NET and how can i call them under my executable project. For example think an arithmetic calculator includes only...
12
by: Ludwig | last post by:
Hi all, we are building our own class library framework, with stuff in it that can be used in various projects at various clients. Initially we had 4 assemblies with everything in it. Of...
10
by: =?Utf-8?B?UGFvbG8=?= | last post by:
Learning C# using Console applications. I want to develop some utility functions (wrapping up some of the Console class methods) so that I can have them available for any program that I write. ...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.