With the .NET toolset you can, but VS.NET doesn't support it directly.
What you want to do is build what's called a multi-module assembly. Each module can be written in whatever language you want, then you link them all together into a single assembly.
Unfortunately, VS.NET only supports single module assemblies, so if you want to go this route you'll need to use the .NET command line tools.
Imagine the file "Dog.cs" is the file that you created in C# that your coworker needs to integrate into his VB project.
--- Dog.cs ---
- public enum DogSize
-
{
-
Small,
-
Medium,
-
Large
-
}
-
-
public class Dog
-
{
-
public Dog(string name, DogSize size)
-
{
-
m_name = name;
-
m_size = size;
-
}
-
-
public string Name
-
{
-
get { return m_name; }
-
}
-
-
public string Bark()
-
{
-
switch (m_size)
-
{
-
case DogSize.Small:
-
return "Yip";
-
case DogSize.Medium:
-
return "Bark";
-
case DogSize.Large:
-
return "Woof";
-
default:
-
throw new InvalidOperationException("The dog is sleeping.");
-
}
-
}
-
-
private string m_name;
-
private DogSize m_size;
-
}
-- Dog.cs --
Compile "Dog.cs" into a module using the following command line syntax:
csc /target:module Dog.cs
Next have your coworker compile his "DogPound.vb" program (written in VB.NET) with a special command line option to include your "Dog.netmodule" Module
vbc /out:DogPound.exe /target:exe /addmodule:Dog.netmodule DogPound.vb
-- DogPound.vb --
- Imports System
-
Imports System.Collections
-
-
Module ConsoleMain
-
-
Sub Main()
-
-
Dim dogs As ArrayList = New ArrayList()
-
-
dogs.Add(New Dog("Pickles", DogSize.Small))
-
dogs.Add(New Dog("Shilo", DogSize.Medium))
-
dogs.Add(New Dog("Dylan", DogSize.Large))
-
-
Dim dog As Dog
-
For Each dog In dogs
-
Console.WriteLine("{0} says {1}", dog.Name, dog.Bark())
-
Next dog
-
-
End Sub
-
-
End Module
-- DogPound.vb --
The result is an Assembly (DogPound.exe) with 2 modules (Dog.netmodule and DogPound.exe). Check it out for yourself by browsing the metadata in ILDASM.exe!
In the example above, you'd probably be better of creating a library for the Dog type and packaging it up in it's own Assembly. That's what I think Microsoft is refering to by being able to use multiple languages in a project. For example, your data services could be written by one team in C# and the user interface could be written by another team using VB.NET (or COBOL.NET if you please).