Ray,
In addition to the other comments. The "easiest" way to ensure that a class
can only be instantiated or used by a specific class is to put both classes
in their own Assembly (Class Library) then make the constructor (Sub New)
for the second class Friend. To restricting the methods called make those
methods Friend also.
' In a class library by themselves:
Public Class Class1
Public Function CreatesClass2() As Class2
Return New Class2
End Function
End Class
Public Class Class2
Friend Sub New()
End Sub
Friend Sub MethodForClass1()
End Sub
Public Sub MethodForEveryOne()
End Sub
End Class
' In a different assembly referencing the above assembly
Dim c1 As New Class1
Dim c2 As Class2 = c1.CreatesClass2()
c2.MethodForClass1() ' error
c2.MethodForEveryOne() ' succeeds
Hope this helps
Jay
"Ray Cassick (Home)" <rc************@enterprocity.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have several classes that has a public interface (nothing really
different there :) ).
1) I would like to ensure that some classes can only be instantiated by
a specific class type.
2) I would like to restrict some public methods from being called only
from another certain class type.
I was trying to figure out a way that I could do this with attributes but
I am coming up empty.
Any ideas?