views:

121

answers:

3

Let say I started a C# project under Windows (Visual Studio 2008) and I want to switch to Mono. Do I have to recompile all the dependencies my project uses, e.g., NHibernate and every single external dependency that comes along ?

Note 1: The reason I asked this question is that I built a project with MonoDevelop on Ubuntu 9.10 and everything went like a charm but when I tried to debug running some tests written with NUnit everything just froze. I have to cancel the running test to get MonoDevelop back up and there is no clear stack trace or hint that I could use to find the problem. So I though that maybe I would need to compile NHibernate (and other dependencies) under Mono/Linux.

+2  A: 

See the Is Mono Binary Compatible with Windows? section of the Mono FAQ.

The answer is that mono is binary compatible, so no you don't need to recompile.

nick
+5  A: 

No, you don't need to recompile DLLs that you reference in code compiled using the Mono compilers.

However, if your user executes the application under Mono rather than the Microsoft.NET framework and the DLL contains calls that aren't supported by the Mono framework, they will run into problems.

There is a Mono migration tool that can analyze your DLLs to see whether they contain any calls that aren't supported for users with Mono.

Likewise, DLLs compiled using the Mono compilers can be referenced by code that is compiled using the Microsoft compiler.

richardtallent
+1  A: 

As the others have said, they are binary compatible.

As an example I recently had need to use the Mono.Cecil.dll to avoid some AppDomain reflection-based pain I was experiencing, and was able to grab the latest version built by the Mono compiler and it ran on my .NET 3.5 runtime with no problems.

Of course if you plan to run on Linux or anything other than Windows, you have to rely on those assemblies being correctly written, so using Environment.NewLine, Path.Combine, etc. instead of windows specific code.

Si