none
Merging Multiple Projects

    Question

  • I have a set of three different projects setup in a solution.  Each project has its own menu to execute a specific set of activities/forms and events for the project within which it resides.

    What I would like to do is to be able to have a main menu residing in one of the projects, or even a different project, that can open any of the menus of the other projects so that I could simulate operating all of the projects as a single entity.  I had thought that this would be easy, but after searching everything I have available to me I have been unable to come up with a solution for this.  

    Could someone tell me how/if this can be done?


    gwboolean

    Monday, April 17, 2017 5:31 AM

Answers

  • What I would like to do is to be able to have a main menu residing in one of the projects, or even a different project, that can open any of the menus of the other projects so that I could simulate operating all of the projects as a single entity.

    If you maintain the projects as separate executables then you would keep them as separate projects and use the Process class in the main menu to execute each executable as it is selected.
    https://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs.110%29.aspx

    If you combine them as one executable in one project then you will open the main form for each part of the application from the main menu in the same way that you instantiate and show any form within a single project.

    You should show what you have tried, and explain which part of it didn't work.

    • Marked as answer by gwboolean Tuesday, April 18, 2017 4:42 AM
    Monday, April 17, 2017 6:57 AM

All replies

  • What I would like to do is to be able to have a main menu residing in one of the projects, or even a different project, that can open any of the menus of the other projects so that I could simulate operating all of the projects as a single entity.

    If you maintain the projects as separate executables then you would keep them as separate projects and use the Process class in the main menu to execute each executable as it is selected.
    https://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs.110%29.aspx

    If you combine them as one executable in one project then you will open the main form for each part of the application from the main menu in the same way that you instantiate and show any form within a single project.

    You should show what you have tried, and explain which part of it didn't work.

    • Marked as answer by gwboolean Tuesday, April 18, 2017 4:42 AM
    Monday, April 17, 2017 6:57 AM
  • I have looked through the info and while most of it is gobbledygook to me, I came up with this solution and perhaps I can get you to evaluate it form Acamar, et. al.

    First I setup a namespace in the project (call it project A).

    Imports System
    Imports System.Diagnostics
    Imports System.ComponentModel
    Namespace DocMaster
        Public Class CallDocMaster
            Public Shared Sub DocMenu()
                Dim DocMenuMain As New Process()
                Try
                    DocMenuMain.StartInfo.UseShellExecute = False
                    DocMenuMain.StartInfo.FileName = "mnuDocMaster.vb"
                    DocMenuMain.StartInfo.CreateNoWindow = True
                    DocMenuMain.Start()
                Catch ex As Exception
                    MsgBox("No Joy!!!!")
                End Try
            End Sub
        End Class
    End Namespace

    As I read the above this should call and open mnuDocMaster.vb from the project (Call it project B).  Of course, "As I read" can mean just about anything.

    Anyway, I placed the following into the menu form code of the project A where the namespace CallDocMaster resides.  However, I am unable to get any further than this as I get the following error:

    "Access of shared member, Constant member, enum member or nested type through an instance;qualifying expression will not be evaluated."

    Public Class mnuMainMasterBase
        Public CallDocMenu As New DocMaster.CallDocMaster
        Private Sub DocMasterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DocMasterToolStripMenuItem.Click
            CallDocMenu.DocMenu()
        End Sub
    End Class
    So the question is, how far off am I and where am I blowing this apart?


    gwboolean

    Monday, April 17, 2017 4:54 PM
  • If I understand you well then you're looking to the configuration manager. It is under the build menu. You can make more assemblies from the projects which are in your solution. I use it for instance to make in one solution a web and a desktop app.

     

    Success
    Cor


    Monday, April 17, 2017 5:04 PM
  • Cor,

    I am able to open the configuration window as shown below.  However, I am unable get the window within window that your information shows above.  Nor do I really know what to do with it if I did.  Can you elaborate some more on this?


    gwboolean

    Monday, April 17, 2017 5:12 PM
  • There are more pages about it on MSDN, be aware it goes a little bit weird.

    https://msdn.microsoft.com/en-us/library/kwybya3w.aspx

    (And don't forget to set the startup projects when you have selected an active one)


    Success
    Cor

    Monday, April 17, 2017 6:01 PM
  • However, I am unable to get any further than this as I get the following error:

    "Access of shared member, Constant member, enum member or nested type through an instance;qualifying expression will not be evaluated."

    What line of code does the error refer to.   Is there a reason for declaring DocMenu as Shared?

    Tuesday, April 18, 2017 12:08 AM
  • Acamar,

    The line was CallDocMenu.DocMenu.  I already worked around that with:

    docMaster.CallDocMaster.Docmenu. 

    So I am now to the point where I can run all code that I setup based on yours and when it runs the catch portion of the Try/Catch falls out. So I am still trying to figure out where I am going wrong.  This is as far as I have gotten at this time.


    gwboolean

    Tuesday, April 18, 2017 3:04 AM
  • So I am now to the point where I can run all code that I setup based on yours and when it runs the catch portion of the Try/Catch falls out.

    So I am assuming that there was no reason for setting the DocMenu method as Shared and that you have changed it.

    What is the error that your Try/Catch is trying to catch and process?  If you don't have an error that you are trying to catch and process then remove your Try/Catch, get the details of any error that occurs at the point where the code fails, fix the problem, and run the application again.

    You should also explain why you are trying to execute a vb file rather than the application (.exe) you want to open and why you are setting it to run without a window - generally, an application created in VB will require a window.
    • Edited by AcamarMVP Tuesday, April 18, 2017 3:13 AM sp
    Tuesday, April 18, 2017 3:10 AM
  • First Acamar, let me show what I am currently running.  Here is the Namespace:

    Imports System
    Imports System.Diagnostics
    Imports System.ComponentModel
    Namespace DocMaster
        Public Class CallDocMaster
            Public Shared Sub DocMenu()
                Dim DocMenuMain As New Process()
                Try
                    DocMenuMain.StartInfo.UseShellExecute = False
                    DocMenuMain.StartInfo.FileName = "mnuDocMaster.vb"
                    DocMenuMain.StartInfo.CreateNoWindow = True
                    DocMenuMain.Start()
                Catch ex As Exception
                    MsgBox("Uh Oh")
                End Try
            End Sub
        End Class
    End Namespace


    The call goes as such:

        Public CallDocMenu As New DocMaster.CallDocMaster
        Private Sub DocMasterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DocMasterToolStripMenuItem.Click
            DocMaster.CallDocMaster.DocMenu()
        End Sub

    As for the share, I thought that was just a name for the routine and did not, of itself, have any significance.  I will make a change to match that now and see if it will clean up the mess I have made.

    I cannot explain why I am trying to execute a vb file instead of an execute file, since I do not really know why.  I will make that change as well.

    • Edited by gwboolean Tuesday, April 18, 2017 3:25 AM
    Tuesday, April 18, 2017 3:13 AM
  • Acamar, I did get things running, and here is what had to be done.

    First, I changed the following line of the code in the namespace from:

    DocMenuMain.StartInfo.FileName = "mnuDocMaster.vb"

    to

    DocMenuMain.StartInfo.FileName = "DocMaster 2.0.exe"

    It took me awhile to find where that file was located, I think in the bin folder

    Additionally, I had to go into the properties for the MasterBase 1.0 project and add a reference, which I found in the Reference Manager Window under Browse. I had to check DocMaster2.0.exe.

    Furthermore, in the DocMaster 2.0 Project, the Startup form needed to be mnuDocMaster.  This is the menu form that I wanted to call up in the first place from the mnuMainMasterBase.vb in the MasterBase 1.0 project.  This project is the startup project for the solution.

    I am not yet entirely sure if this covers the sequence of required events to get this done, since I was mucking around with a lot of stuff.  However, it works and I am going to see if I can get this to work for a several other projects in the solution.

    Thanks for the help, but it would have been nice to have just a little more detail about some of the additional requirements to make this work.  On the other hand, I guess I will remember better having to find that for myself.


    gwboolean

    Tuesday, April 18, 2017 4:42 AM
  • I am not yet entirely sure if this covers the sequence of required events to get this done, since I was mucking around with a lot of stuff.  However, it works and I am going to see if I can get this to work for a several other projects in the solution.

    If you use 'known' folders you can make the location consistent between development and deployment, but for development you will need to add a copy procedure following compile.  The alternative is to use some debug constants.

    https://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx

    https://msdn.microsoft.com/en-us/library/aa833213(v=vs.100).aspx
    https://msdn.microsoft.com/en-us/library/42x5kfw4.aspx

    https://msdn.microsoft.com/en-us/library/76zdzba1(v=vs.100).aspx

    Tuesday, April 18, 2017 4:49 AM
  • I have the full sequence down now, as I setup another project to do the same thing.  Here is the sequence of events and requirements.

    The Startup project for the solution is SiTechMasterBase 1.0. 

    1. The project that I want to call/execute is ValMaster 2.0. and in the properties, the Startup form was set to mnuValMaster.vb.

    2.  In SiTechMasterBase 1.0 the startup form was set to the form  mnuMainMasterBase.vb.

    Now comes the tricky part.

    In the SiTechMasterBase 1.0 project Properties I selected the References window. 

    I then clicked the add Reference button, selected refernce to open the Reference manager window.

    Thin I selected browse (On the side) and used the browse button to find ValMaster 1.0.exe, which I then checked, as seen in the window then clicked OK.

    At this point the following code was placed in the Namespace:

        Public Class CallValMaster
            Public Shared Sub ValMenu()
                Dim ValMenuMain As New Process()
                Try
                    ValMenuMain.StartInfo.UseShellExecute = False
                    ValMenuMain.StartInfo.FileName = "ValMaster 1.0.exe"
                    ValMenuMain.StartInfo.CreateNoWindow = True
                    ValMenuMain.Start()
                Catch ex As Exception
                    MsgBox("No Joy!")
                End Try
            End Sub
        End Class

    The event used to call the ValMaster menu from the Main menu was as follows:

        Private Sub ValMasterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ValMasterToolStripMenuItem.Click
            ProjectMenu.CallValMaster.ValMenu()
        End Sub

    This incorporates the information that you provided with your link, plus the actions required to get the code to do the job.  It Works.

    Thanks for the help on this.


    gwboolean

    Tuesday, April 18, 2017 5:34 AM