Accessing Public Function located in another Project referenced within the same Solution

I've to a solution with two projects:
Bungalow
New Programs
New Programs has a ref to Bungalow.
Bungalow has a Module called Bungalow which has a Public Function (clone_control())
From within 'New Programs' I can not access Clone_Control.
However, if I drag (wihin the Solution Explorer) the Bungalow module from Bungalow to New Programs, then it works OK.
I thought that adding a reference was like letting all the contents of the referenced project be "in" in the referring project.
Is this just the way it works or am I missing something
MORE INFO
In addition, if I type "bungalow." I get intellisense only for the FORM and CONTROL files in the Bungalow project, not the Bungalow.vb module.
(BTW, I also tried this by creating a module in Project Bungalow called 'eraseme' and public sub within that demonstrates the same symptom.



Answer this question

Accessing Public Function located in another Project referenced within the same Solution

  • jlawing

    Have you considered making both projects part of the same Solution (Maybe that's what you meant by dragging one into the other...)

    Part of the problem is that with Win32 applications, Microsoft makes it hard for one program to interfere with the workings of another internally. (Encourages the programs to cooperate using "official" systems like sending messages...)


  • angelbear

    In all of these examples, all projects are in the same solution, and the primary project has a reference to secondary project.
    SOLUTION
    1. Both projects in same solution. (Already did this)
    2. Calling project must have a Reference to the Called project.
    3. Need to use Imports <called project>
    Thanks for the feedback. Knowing that it SHOULD work is half the battle!


  • damy

    In addition to the reference you either need to fully qualify the name or use an imports statement:

    Class NewPrograms

    Private Sub Test

    Bungalow. Bungalow.clone_Control

    end sub

    end class

    OR

    Imports Bungalow.Bungalow

    Class NewPrograms

    Private Sub Test

    clone_Control

    end sub

    end class



  • ElizabethS

    try this simple example

    Create two Console application projects in a solution

    ConsoleApplication1 would be the project that you are going to rum - the code will look something similar to this.

    Public Module Module1

    Sub Main

    Console.Writeline("App1")

    ConsoleApplication2.Module1.Foo

    End Sub

    End Module

    Add a reference to ConsoleApplication2 in the ConsoleApplication1 project.

    Console Application2 will be very similar

    Public Module Module1

    Sub Main

    Console.Writeline("App2")

    End Sub

    Public Sub Foo

    Console.Writeline("App2 Foo")

    End Sub

    End Module

    If you run ConsoleApplication2 then you should get some output like

    App2
    App2 Foo

    If you run ConsoleApplication1 then you should get

    App1
    App2 Foo

    This should work....


  • Skidmark

    That's exactly how I thought it should work. But it doesn't.
    I tried both of the above (seperately and combined, just in case). I get the same symptoms. (intellisense doesn't work,I get an error that the project (bungalow) is undefined). Also, when I type "imports" and use intellisense, it does not show me the other project as an option.
    FYI, I'm using VB.net in VS 2005.
    I looked in New Programs and it lists Bungalow.exe as a reference.
    Any ideas


  • Izu

    Also you may want to check the module itself is also public as well, otherwise a public function inside a private module will not be visible from the other project.

      

    Also you may want to check the module itself is also public as well, otherwise a public function inside a private module will not be visible from the other project.

    Public Module Bungalow

     Public Sub clone_Control

    ...

    End Sub

    End Module

     

     With this Bungalow.Clone_control should be visible to other projects that reference it.   You may want to check the Project Properties as to what the root namespace is.    If it is set to something then you will either need to use the imports statement or when calling the method use the fully qualified name

    <Namespace>.Bungalow.Clone_control

     

     


  • Accessing Public Function located in another Project referenced within the same Solution