Is possible to join code of different programming languages in single solution/application? RRS feed

  • Question

  • Hi!

    I'm working in Visual Basic. I have sources in three programming languages and need it to join to single solution and compile as single application.

    Part is in C (C I'm learning now)
    Part is in C# (know not)
    Part is in Visual Basic (created by me personally)

    Like you see I'm able to modify Visual Basic part, but other not.

    My Q is simple, but don't know if is answer simple too:

    Is possible to join different programming languages sources to single solution and compile to single app?

    Thank you for each reply.


    Tuesday, June 27, 2017 10:25 PM

All replies

  • Hello,

    Yes it's possible. I would assume you want all code to interact which is possible too.

    In the following solution the bold project is which depend on two C# projects.

    See this blog post in regards to C called from

    Please remember to mark the replies as answers if they help and unmark 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.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, June 27, 2017 10:35 PM
  • Part is in C# (know not)
    Part is in Visual Basic (created by me personally)

    VB.NET and C# are .NET assemblies,  and they can talk to each other because of the .NET Framework if you have created both programs to talk to each other.

    C is kind of questionable if a .NET program can communicate with it. You can find out by using Bing or Google.

    Tuesday, June 27, 2017 10:44 PM
  • In my opinion, the C code can be accessed from C# and VB if it is placed inside a Dinamic-link Library (.dll file), which exports some functions. Then in C# and VB you will define these functions using DllImport attribute.

    It is easier if you put the C code inside a C++/CLR Class Library. Then you can define some public classes (‘public ref class’), which execute the C code and can be directly accessed (created with new) from C# and VB by adding a project reference using Add Reference dialog.

    But you have to choose between 32-bit and 64-bit configurations, because “Any CPU” is not available.

    • Edited by Viorel_MVP Wednesday, June 28, 2017 5:34 AM
    Wednesday, June 28, 2017 5:30 AM