C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Friend Assemblies


Posted Date: 03 May 2006    Resource Type: Articles    Category: .NET Framework
Author: phanindra yerraMember Level: Gold    
Rating: 1 out of 5Points: 10



Introduction



This is new feature in c# 2.0. Suppose in your assembly some members are inaccessible but u want to access in other assembly of your project for example say enhancement of your project. What you will do? ,Suppose if you make the accessors of members you want to access outside the assembly to public. Then here the problem is that members are accessible in all other assemblies. But you must restrict it what you will do?
Here Friend assemblies plays the game .

Let us look an example



All the non-public types in an assembly can be accessed by another assembly, if the first assembly is declared as a "friend" of the second. A friend assembly is declared by using the InternalsVisibleToAttribute class.
For example, assume a large project contains two assemblies, A and B. Assembly B needs access to a type contained in assembly A, but this type has been declared as internal to prevent unauthorized use. Assembly A can declare assembly B as a friend, and as such, assembly B can access the non-public types of assembly A as if they were part of the same assembly.
Note that this does not mean that assembly A can access types in assembly B. To achieve that, assembly B would also have to define assembly A as a friend assembly.
Also, if another assembly, C, is declared a friend of assembly B, and assembly B is a friend of assembly A, assembly C does not automatically become a friend of assembly A.


Summary



This main aim of writing this article is to expose one of the new feature of c#.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Friend Assemblies  .  Feature in c# 2.0  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: VS2005 problem: Visual Basic compiler is unable to recover from the following error
Previous Resource: How to retriew and Update App.config file. Part I
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use