none
Can there be two projects (C# and the other VB.Net) in the same solution RRS feed

  • Question

  • Hello

    Can there be two projects (C# and the other VB.Net) in the same solution? if so how do you call a VB form from a C# button click

    regards

    Manoj Gokhale

    Monday, July 8, 2019 10:46 AM

All replies

  • Hello, 

    There could be any number of projects in any number of available languages. Just require to compilable to .Net type libs.

    You need to add reference (in the project explorer in Studio). In you case reference to VB project to C# project. 


    Sincerely, Highly skilled coding monkey.

    Monday, July 8, 2019 10:54 AM
  • In your C# project add a reference to yout VB project.

    In your C# project add code to a Button_Click Event just like this:

            private void Button4_Click(Object sender, EventArgs e)
            {
                var vbwindow = new WinFormsVB.Form1();
                vbwindow.Show();
            }
    

    Monday, July 8, 2019 11:15 AM
  • Hello,

    • Both the C# project and the VB.NET projects need to use the same .NET Framework release, otherwise when attempting to access functionality from one project to the other it will not work.
    • In some cases a method in C# will need to have [] surround the method name if a key word, usually this happens with fluent design patterns.
    • The function or property to access needs to be marked as public.



    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, July 8, 2019 11:17 AM
    Moderator
  • Hi,

    see the following link;
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/d584777e-fcc7-40d6-9ea3-99463f541683/c-project-and-vb-project-how-can-i-call-a-form?forum=csharpgeneral

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 9, 2019 8:07 AM
    Moderator
  • I assume you mean to ask if an application (exe file) can use more than one language. It is possible to put many projects, each for a separate exe file, in a solution. Also it is possible to use separate solutions for each of the pieces I describe in the following.

    There is one critical point that has not been mentioned. At least one of the projects must be a Class Library. If you are familiar with other languages then you are probably familiar with other ways to combine languages but for .Net we need to use Class Libraries for all the pieces except the main project. You can use one language for the main application (the exe) that uses one or more Class Libraries in other languages.



    Sam Hobbs
    SimpleSamples.Info


    • Edited by Simple Samples Tuesday, July 9, 2019 7:51 PM clarification
    Tuesday, July 9, 2019 7:32 PM
  • Just require to compilable to .Net type libs.

    You probably meant to say .Net Class Library.


    Sam Hobbs
    SimpleSamples.Info

    Tuesday, July 9, 2019 7:36 PM