Friend variable scope not accessable through object

Discussion in 'ASP .Net' started by Dominic, Nov 3, 2004.

  1. Dominic

    Dominic Guest

    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.
    Dominic, Nov 3, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Sabine
    Replies:
    3
    Views:
    419
    =?Utf-8?B?U2hhdw==?=
    Jan 28, 2005
  2. Bruce Hodge
    Replies:
    0
    Views:
    400
    Bruce Hodge
    Feb 15, 2006
  3. Jim Walseth
    Replies:
    0
    Views:
    291
    Jim Walseth
    Oct 23, 2003
  4. william

    web service is not accessable

    william, Nov 16, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    101
    william
    Nov 16, 2007
  5. Replies:
    1
    Views:
    47
    Chris Angelico
    Mar 18, 2014
Loading...

Share This Page