"You can create assemblies consisting of types implemented in different programming languages. [& Hellip;]"
I'm not sure if this actually adds much value to the real-world scenario, (a) because Visual Studio does not support project links for network modules, and (b) since you can get the same benefits from assemblies.
There is one noticeable difference between an approach with multiple assemblies and multiple files: one assembly by default cannot access other types of assemblies that have internal / Friend visibility (for example, an assembly). If you compile modules instead, and then link them to a single assembly of several files, a module compiled from C # could access the internal types of the module compiled using VB.NET (and vice versa).
Below you will find a brief description of this.
CsharpClass.cs:
internal class CsharpClass { }
VbClass.vb:
Friend Class VbClass : End Class
Program.cs:
public static class Program { public static void Main() { var vbClass = new VbClass(); var csharpClass = new CsharpClass(); } }
Build a script for network modules:
csc.exe /t:module /out:CsharpClass.netmodule CsharpClass.cs vbc.exe /t:module /out:VbClass.netmodule VbClass.vb csc.exe /t:exe /out:Program.exe /addmodule:CsharpClass.netmodule /addmodule:VbClass.netmodule Program.cs
This build will work and run without any errors.
Note that there is nothing magical about the .netmodule file .netmodule ; this is only a convention, but the output file is a regular .NET DLL.
Build script for assemblies:
csc.exe /t:library /out:CsharpClass.dll CsharpClass.cs vbc.exe /t:library /out:VbClass.dll VbClass.vb csc.exe /t:exe /out:Program.exe /r:CsharpClass.dll /r:VbClass.dll Program.cs
This build will fail because:
Program.cs(5,27): error CS0122: 'VbClass' is inaccessible due to its protection level Program.cs(5,23): error CS0143: The type 'VbClass' has no constructors defined Program.cs(6,31): error CS0122: 'CsharpClass' is inaccessible due to its protection level Program.cs(6,27): error CS0143: The type 'CsharpClass' has no constructors defined