Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Visual Studio Linking Projects

Options
  • 10-11-2010 6:35pm
    #1
    Closed Accounts Posts: 214 ✭✭


    Hey does anyone know how to pass values between two project in visual studio? I need one project to be able to access functions in another.
    Thanks.


Comments

  • Registered Users Posts: 981 ✭✭✭fasty


    What language? What type of project?


  • Closed Accounts Posts: 214 ✭✭Assmaster_Kronk


    fasty wrote: »
    What language? What type of project?

    They're both C++, one project is just a console, the other is a window and a console. I'm trying to pass values from the console only project to the windowed one.


  • Registered Users Posts: 2,781 ✭✭✭amen


    you can't just pass values between project even if they are in the same solution.
    Project A
    Project B

    If you want Project B to access/accept a value from Project A you need to add a reference(or invoke Project A) to Project B and then access the relevant methods in A.


  • Registered Users Posts: 981 ✭✭✭fasty


    In C++ one of the projects would need to be a static library or a DLL and the other project would then link against it.


  • Closed Accounts Posts: 214 ✭✭Assmaster_Kronk


    fasty wrote: »
    In C++ one of the projects would need to be a static library or a DLL and the other project would then link against it.

    I'd assume i can't reference both projects with a 3rd static library project, as they would be using two different instances of the class?


  • Advertisement
  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    I'd assume i can't reference both projects with a 3rd static library project, as they would be using two different instances of the class?

    You can share code between multiple different binaries using DLLs, but they're not using the same instances, just a common library. Moving/sharing data between two separate running apps though, which appears to be what you're asking about, is a different story. You could either do that using some shared data store to have them work off the same data (a file or database or some such), or using one of a few different techniques to share data or use exposed interfaces more directly. "Inter-process communication" is the general term for this kind of thing, Google should turn up something suitable - pipes, sockets, COM, message queues or memory-mapped files would be a few of the methods that can be used in Windows. With .NET code, you'd probably be looking at WCF for this sort of thing.


  • Registered Users Posts: 981 ✭✭✭fasty


    I'd assume i can't reference both projects with a 3rd static library project, as they would be using two different instances of the class?

    Correct, statically linked libraries are a compile time thing so each process would still be independant, just reusing shared code.

    NeverSayDie's post about IPC pretty much covers all the bases. Which one is best for you would depend on what you are trying to do.


  • Closed Accounts Posts: 214 ✭✭Assmaster_Kronk


    fasty wrote: »
    Correct, statically linked libraries are a compile time thing so each process would still be independant, just reusing shared code.

    NeverSayDie's post about IPC pretty much covers all the bases. Which one is best for you would depend on what you are trying to do.

    Cool, i'll look into it:D


Advertisement