Hello,
Question
Is it possible to create assembly which contains two or more .netmodules?
If yes, how to achieve that?
Which tool should I use?
I do not want to reference them, I want to put modules inside assembly.
I already found that there are several tools which are able to link/merge/embed/reference modules into one assembly.
But, none of tools are doing exactly what I want.
Here is what tried already:
I have two source files: L1.cs, E1.cs.
class L1
{
public string GetMsg()
{
return "Hello, L1 here.";
}
}
public static class E1
{
public static void Main(string[] args)
{
Console.WriteLine("Hi, I'm Main!");
L1 c = new L1();
Console.WriteLine(c.GetMsg());
}
}
With C# compiler, from Visual studio command prompt, I am able to create modules:
> csc -t:module -out:L1.netmodule L1.cs
> csc -t:module -out:E1.netmodule -addModule:L1.netmodule E1.cs
Option 1: Visual C++ Linker
> link -out:MyDll.dll /ltcg /dll *.netmodule
But, according to manifest there is only one module in assembly MyDll. Source code is there, but there is only one module (maybe I am reading it in wrong way :?)
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 4:0:0:0
}
.assembly MyDll
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module MyDll.dll
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0002
.corflags 0x00000001
Option 2: Assembly Linker
I tried:
al -t:library -out:MyDllAl.dll E1.netmodule L1.netmodule
Results are not what I wanted.
There are more modules, but they are not part of MyDllAl.dll assembly. They are referenced :(.
Option 3: IlMerge, IlRepack
I already used IlMerge - results are disappointing - only one module in assembly.
I haven't tried IlRepack, but according to documentation it's 'clone' of IlMerge (there are few differences, but results are same).