Access another project in same solution.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • blue_nirvana

    Access another project in same solution.

    How do you access a form or code from another project in the same solution?
    I have a solution that has several projects and I want to be able to load a
    form or call code from say Project2 from Project1. I thought it would have
    been something as simple as Project2.Whatev er, but that does not work.

    Thanks
  • Carlos J. Quintero [VB MVP]

    #2
    Re: Access another project in same solution.

    It depends:

    - If you want to access the code from the other project once compiled
    (assembly), you need to add a reference, either an assembly reference or a
    project reference (the Add Reference dialog has 3 tabs, explore them).

    - If you want independent assemblies at run time with no dependencies, only
    sharing code at source code level, you can link a file from one project in
    another project, using the Add Existing Item dialog, navigating to the file
    of the other project, and instead of clicking the Open button, drop down it
    and select the Link File option.


    --

    Best regards,

    Carlos J. Quintero

    MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
    You can code, design and document much faster.
    Free resources for add-in developers:
    MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.


    "blue_nirva na" <bluenirvana@di scussions.micro soft.com> escribió en el
    mensaje news:1D6027AB-8773-4ABF-97B9-6BE15C8E669C@mi crosoft.com...[color=blue]
    > How do you access a form or code from another project in the same
    > solution?
    > I have a solution that has several projects and I want to be able to load
    > a
    > form or call code from say Project2 from Project1. I thought it would
    > have
    > been something as simple as Project2.Whatev er, but that does not work.
    >
    > Thanks[/color]


    Comment

    • James Thresher

      #3
      Re: Access another project in same solution.

      You will need to add a reference to the other project, you can do this
      by going to Projects/Add Reference and select the Projects tab, this
      will show all of the projects in your solution. Once you have referenced
      the other project you should be able to use its objects.

      blue_nirvana wrote:[color=blue]
      > How do you access a form or code from another project in the same solution?
      > I have a solution that has several projects and I want to be able to load a
      > form or call code from say Project2 from Project1. I thought it would have
      > been something as simple as Project2.Whatev er, but that does not work.
      >
      > Thanks[/color]

      Comment

      • blue_nirvana

        #4
        Re: Access another project in same solution.

        Thanks for the response. I tried adding a reference, but it tells me that an
        assembly must have a .dll extension in order to be referenced. I guess I
        have to compile the project inot a .dll? How?

        "James Thresher" wrote:
        [color=blue]
        > You will need to add a reference to the other project, you can do this
        > by going to Projects/Add Reference and select the Projects tab, this
        > will show all of the projects in your solution. Once you have referenced
        > the other project you should be able to use its objects.
        >
        > blue_nirvana wrote:[color=green]
        > > How do you access a form or code from another project in the same solution?
        > > I have a solution that has several projects and I want to be able to load a
        > > form or call code from say Project2 from Project1. I thought it would have
        > > been something as simple as Project2.Whatev er, but that does not work.
        > >
        > > Thanks[/color]
        >[/color]

        Comment

        Working...