D
Dominic
I have 'project1' whereas I use the classes/modules of that assembly
in 'project2'. If an item in project1 is declared as 'object', the
properties and methods on that object declared as friend are not
accessable. A simple example:
create a class library 'project1' with the following:
Public Class myPublicClass
Friend Function myFriendFunction()
End Function
End Class
Public Class myTestClass
Public TestScope As Object
Public Sub New()
TestScope = New myPublicClass
TestScope.myFriendFunction()
End Sub
End Class
Now compile/create the assembly. In another project try:
dim TestProject1 as project1.myTestClass = new project1.myTestClass
This will error as: Public member 'myFriendClass' on type
'myPublicClass' not found
Now here is the catch! In project1.myTestClass, change the
declaration type of TestScope from 'Object' to 'myPublicClass' and
execute the test case again. It works! Why doesn't the first
scenario work and the second does? And this is just a simple example,
my real-world situation dictates that the variable may be one of
several different classes so it's type would be the generic 'Object'.
Please don't offer the solution of typing the variable as the specific
class. Any help/explanation is appreciated.
in 'project2'. If an item in project1 is declared as 'object', the
properties and methods on that object declared as friend are not
accessable. A simple example:
create a class library 'project1' with the following:
Public Class myPublicClass
Friend Function myFriendFunction()
End Function
End Class
Public Class myTestClass
Public TestScope As Object
Public Sub New()
TestScope = New myPublicClass
TestScope.myFriendFunction()
End Sub
End Class
Now compile/create the assembly. In another project try:
dim TestProject1 as project1.myTestClass = new project1.myTestClass
This will error as: Public member 'myFriendClass' on type
'myPublicClass' not found
Now here is the catch! In project1.myTestClass, change the
declaration type of TestScope from 'Object' to 'myPublicClass' and
execute the test case again. It works! Why doesn't the first
scenario work and the second does? And this is just a simple example,
my real-world situation dictates that the variable may be one of
several different classes so it's type would be the generic 'Object'.
Please don't offer the solution of typing the variable as the specific
class. Any help/explanation is appreciated.