You might have had some problem in the past where you want to share methods of your 'Friend Assembly' to a particular assembly or assemblies. Now in VB 9.0 you have a way! for this you just have to use an assembly level attribute 'InternalsVisibleTo' (can be found under System.Runtime.ComplierServies) which takes the name of the assembly to which you want to share your methods without extension.
To understand this suppose you have made a Class Library Project say 'testFriend' and write the following code for the class:
Friend Class FriendofDemoClass
.......Function SomeFunction() As Integer
..............Return 0
.......End Function
End Class
Now create a 'Console Application' 'Demo' and after adding the refrence of 'testFriend' make an object of 'FriendofDemoClass' when you make an object of this class outside its scope ('Friend' can only be accessed within the scope of its assembly) you get this error.
Now go back to your 'testFriend' Library and add the 'InternalsVisibleTo' attribute which can be found under System.Runtime.CompilarServices.
Imports System.Runtime.CompilarServices
Now everything works fine !
1 comment:
Please leave your comments.
Post a Comment