[Mono-devel-list] Compiling to DLLs and then statically linking them into a PE

A Rafael D Teixeira rafaelteixeirabr at hotmail.com
Sat Aug 30 19:30:25 EDT 2003

>From: Chris Seaton <chris at chrisseaton.com>
>To: mono-devel-list at lists.ximian.com
>Subject: [Mono-devel-list] Compiling to DLLs and then statically linking 
>them into a PE
>Date: Sat, 30 Aug 2003 22:42:43 +0100
> >From the FAQ:
>Question 82: Is it possible to build a C# file to some sort of
>intermediate format which can linked into a final module, like the
>traditional .c -> .o -> .so path?
>You can use:
>mcs /target:library file1.cs, mcs /target:library file2.cs, mcs
>/target:exe file1.dll file2.dll /out:mybin.exe
>In this example, if I have a class defined in file1 that file2 uses, and
>another class defined in file2 that file1 uses, will the commands work,
>or will the compiler fail?
>To compile file1 the compiler would need the meta data from file2, I
>would have thought.
>I've run into this problem before, as I originally wanted to use make to
>compile my C# programs.
>Chris Seaton
>chris at chrisseaton.com

If you REALLY don't want to compile file1.cs and file2.cs to a SINGLE 
assembly (DLL),  what given their circular references, would be the obvious 
thing to do, you can use the classic solution: refactor their dependencies 
into interfaces on yet another assembly that both reference and that both 


using file2;
public class c1 { public void DoSomething(c2 thing) ... }
using file1;
public class c2 { public void DoSomethingElse(c1 thing) ... }

public interface i1 { public void DoSomething(i2 thing); }
public interface i2 { public void DoSomethingElse(i1 thing); }
using file0;
public class c1 : i1 { public void DoSomething(i2 thing) ... }
using file0;
public class c2 : i2 { public void DoSomethingElse(i1 thing) ... }

Hope it helps,

Rafael Teixeira
Brazilian Polymath
Mono Hacker since 16 Jul 2001

MSN Messenger: instale grátis e converse com seus amigos. 

More information about the Mono-devel-list mailing list