1

I was wondering if I can merge ASP.Net VB and ASP.Net C#. I made my research and some of the netizens said no here. And this blog and this blog said it is possible. I was wondering if it is possible, how can I access the class of ASP.Net VB to the class of ASP.Net C# from different project?

7
  • 1
    Nobody says no. You misunderstood what you read - that was about using different languages in the same project. Project or no, in the end you have a reference to an assembly. The language used to create the assembly doesn't matter. If it did, you wouldn't be able to use any NuGet package as they are all built using C# Commented Jun 15, 2017 at 10:58
  • 1
    You have to have different projects, one VB.net the other c#. To access the class of ASP.Net VB from the class of ASP.Net C# project you simply reference the other project. Please read up on "Project References in Visual Studio" - Google, look at images, follow tutorial of both "solution with VB.net & C# projects" Commented Jun 15, 2017 at 11:00
  • Ignoring the technical aspect, This would be horribly confusing and would mean if your company employed anyone in the future they would have to understand (and more importantly want to work with..) both languages. Pick one and stick to it. Commented Jun 15, 2017 at 11:05
  • @JeremyThompson I will gonna try that. Have you already tried it? Commented Jun 16, 2017 at 1:36
  • @Liam I'm not a fan of VB, and yes my company uses VB and somehow I want to write in C# those new features that my company want to add. Commented Jun 16, 2017 at 2:09

3 Answers 3

2

If they are in different projects, absolutely... Once compiled .Net assemblies can be referenced and accessed regardless of .Net language.

I don't believe however that you can mix source files in the same project, as both use different compilers to compile to IL.

And finally, if you are talking about uncompiled scripts in App Code folder, I'm not sure. I don't work with uncompiled code files due to security reasons.

Sign up to request clarification or add additional context in comments.

2 Comments

If it was in a different project, and it is written in different languages, can I still access all of their classes vice versa?
Assuming that they are public classes, properties and methods, yes.
2

It is possible to convert two different languages project into one. Simply follow these steps:

  1. Compile VB.Net project
  2. add library references of compiled project into another project which is in ASP.Net C#
  3. Now instantiate the object of referenced library in you C# code and you can access all methods of VB.Net project.

Please don't forget to +1 the answer if it helped. Cheers!

1 Comment

I will definitely try this, if it's successful, I'm going to mark this as an answer
1

If you are thinking of creating single ASP.NET project from multiple ASP.NET project which are written in different programming language then that is not possible. Here by creating I mean to say including c# file and vb file in a single project.

But if you are going to add reference (dll reference) of those project in a new project then that is possible.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.