user3273580 user3273580 - 2 years ago 104
C# Question

Multiple Language Projects in Visual Studio

I've recently learned of the joys of compiling projects into dlls to use them in other projects! However, now I'm trying to streamline a process where I have two projects, one written in C# and the other in VB, where the C# project has dependencies on a dll compiled from the VB process.

What I'm hoping I can achieve:
- Have both of these projects viewable within the same VS project

  • Pull updates on the VB code from SVN and compile them into a dll located
    in a folder within the project

  • Not have to update my references in the C# project as I am updating the same dll in the project.

  • Build the C# project whenever needed, without rebuilding the VB project

Can this be done?


Answer Source

Is this a VB.NET project? If so, you're in luck.

1) You cannot have a Visual Studio project that uses multiple languages (unless you count ASM in C/C++). However, a single Visual Studio solution can have multiple projects where each project uses a different language.

2) If the projects are C# and VB.NET (or F# or Managed C++ or any other language that produces a .NET assembly), there is little difference in the output assemblies of one versus the other. A C# project can reference an assembly built with VB.NET and vice-versa.

3) If the projects are in the same Visual Studio solution, you can use Project References instead of Assembly References. Project References make it so that one project depends on the output of another project in the same solution. You establish the project reference once (in VS2015: Right-click Project => Add => Reference... => Projects => select the project to reference). And then Visual Studio/msbuild automatically knows the correct order to build them (and whether or not to build them at all). It's even smart enough that if you change the output location of the referenced project, you don't need to do anything to the referencing project.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download