Is it possible to link a C# form to a VB.NET project?

Asked

Viewed 1,180 times

8

I have two different projects, one with only one form in C#, I can embed the form in my project in VB.NET ?

  • 3

    Yes, you can. But not the form source code. You need to compile the C# project that has the form and then reference the generated Assembly in your VB project. Then you can use this form in the VB project just as you use any other class of the .Net Framework or any third party library.

  • Would you have a link or an explanation of how this reference is made? @Caffé

2 answers

6


Are two options:

  • Convert the code c# to Vb.net, see this Ferrament C# to Vb.NET Converter
  • As stated by Caffé, put the C# form in a separate project, and use the form in the VB.NET project.

To open the C# form in VB.NET, if the two projects are in the same solution:

Dim  csharpfrm As New ProjetoCSharp.Form1
csharpfrm.Show()

I am currently without Visual Studio, but to add the reference do the following: In the project with form C#, click on project >> options, and change the project type to dynamic library.

Compile the project (Build, build Solution, I don’t know how it looks in English).

Then, in the VB project, in the solution explorer, right-click the project, add, references, and find the file. dll in C#project folder, sub folder bin release.

  • More information here, but it’s in English. If this is a problem I will update the answer: http://www.vbforums.com/showthread.php?270506-How-to-call-C-form-from-a-VB.NET-form

  • I will test tonight, thank you @Rsinohara.

2

Create a project in the same solution in C# and another in VB, in C# puts your project, when using this C# project in VB, refer it to your project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.