Compiling libraries with Mono 3

Hi,

I´m struggling setting up a pipeline to develop external libraries using MonoDevelop (on Win7).

Before that I´ve successfully created a pipeline using VS2012 to compile a library using .Net 3.5. but since I want to use Mono.CSharp I think need to switch to Mono to compile and deploy the lib in Unity.

I´m now getting confused because I get compile errors with parameter default values when I compile the library with Framework 3.5 in MonoDevelop although Unitys own Mono version does not complain. Switching to Framework 4.0 in MonoDevelop solves the compile error but then Unity does not accept the library anymore…

How do I setup a stable pipeline for compiling Mono scripts using MonoDevelop without the issues above? Can I use the latest versions of Mono (3.0.9) and MonoDevelop to compile the external libraries?

Thank you for your help.
xad

I use a Visual Studio to great DLLs for Unity and it works fine. What are you wanting to use in Mono.CSharp?

I´d like to use Mono.CSharp to compile and execute scripts at runtime. Is there a way to reference the Mono.CSharp.dll in VS2012 successfully while compiling everything with Microsoft .NET?

I´ve checked out the sources of Mono from [here][1] and compiled the Mono.CSharp project myself. As it happens this library can only compiled with target framework .NET4.0 or higher. If I set it to .NET3.5 I get several compiler issues. There are also explicit guards in the code checking for .NET4.0 or higher. So it seems its not possible to create a library which can be used with .NET3.5... I guess that rules out using Mono.CSharp in an external lib does it? [1]: https://github.com/mono/mono/tree/master/mcs/class/Mono.CSharp

Ok I got it working! My previous comment was based on wrong assumptions. There was a "Conditional compilation symbol" set in the Mono.CSharp project settings which lead to my errors above using .NET3.5 as target. Removing this symbol I was able to build Mono.CSharp with target .NET3.5 and include it into my library project without problems. Eventually I successfully tested dynamic compilation and execution of C# code provided as string at runtime with Unity.

2 Answers

2

You should be able to use Mono.CSharp with .net.

In any case MonoDevelop uses .net by default on windows. This is why you’re seeing the behavior with default parameter specifiers - when you select .net 3.5, MD is using the c# compiler from the .net 3.5 framework, which doesn’t support default parameters.

Thanks Tak, I have used Xamarin 4 which seems to be the latest MonoDevelop version now and selected "Mono / .NET 3.5" as target framework. If I understand you correct the Xamarin just used .Net to compile which lead to the default parameter errors, right? What I do not understand is the fact that my VS2012 library project compiled with .NET 3.5 does not complain about the default parameters. How does that make sense? Following the previous post, how can I incorporate Mono.CSharp into a .NET project build?

I have solved this issue by downloading the Mono.CSharp code from GitHub and compiling it with target framework .Net3.5. I had to remove the Conditional compilation symbol “NET_4_0” from the project settings to do this successfully. I could reference the resulting library file correctly in my own library project (for Unity) and eventually compile and run C# code at runtime in my Unity project. The code had been provided via string using the “Evaluator” class for execution. More details regarding Mono.CSharp can be found here.