.NET version in Unity

I’ve been coding away on my first C# plugin, and run into trouble.

I get an error message like this when calling certain methods:

Could not load file or assembly ‘System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ or one of its dependencies.

I use Linq a lot in my plugin, and now I have ran my head straight into the wall on this. Linq is a .NET 3.5 feature, and now I worry that Unity doesnt support this yet.

Sorry if this is a noob question, but I’m quite new to C# and Unity.

What do I have to do to get this working?

Hi Thomas,

bad news: Unity 2.0 supports only .NET 2.0. So Linq is pretty much out of sight for use with Unity - unless you use it on a Web server that Unity accesses through HTTP :wink:

Generally speaking, it’s a good idea to avoid stuff that’s not in mscorlib.dll in Unity - at least if you plan on creating a Web player, because that will significantly increase the download size, as the relevant DLLs must be included with the download.

Of course, it really depends on what you’re doing… But .NET 3.5 probably will not work at all… I’m not sure if Mono does support the 3.5 features, yet (I would suspect not)…

Sorry for the bad news…

Sunny regards,
Jashan

Oh that is bad news indeed.

Will try to copy over Windows DLL’s until it works and see how much they are.

Its for my smartfoxserver client API. Its translated and works in a standalone C# client, but not in Unity. Now I know why.

Damn damn, but thanks for the reply!

Just FYI, the latest version of Mono is 1.9 released in March 2008.

The release notes are here:
http://www.go-mono.com/archive/1.9/

Seems to have added some kind of LINQ support.

Looks like C# 3.0 is the default now. Also read that LINQ to objects and XML is part of 1.9, but not LINQ to SQL.

Cheers
Shaun

Aha!!!

But wont I have to wait for the Unity boys to upgrade first before I can safely use this?

(Sorry - never spend much time looking into .net/mono)

/T

Correct

Your LINQ life is totally in the hands of the UT guys :slight_smile:
We’ve just implemented a whole bunch of platform WCF services using LINQ to SQL - its so nice, I can’t ever imagine going back.

We want to update to new Mono version very carefully. So yeah, we’ll do it at some point, but don’t know exactly when.

Before releasing Unity 2.0 we spent two months fighting bugs in a pre-release version of Mono, and we don’t want to go there again. Stable versions only.

(why we tried to use a pre-release version? because the stable one at that point had some annoying memory leaks)

Very true. I should’ve mentioned that 1.9 is a Pre-release/Beta for 2.0. Probably better to sacrifice LINQ for a stable non-memory leaking Unity :slight_smile:

Just to clear out some confusion about versions here:
Unity 2.0 uses Mono version: 1.2.6 ?
http://www.go-mono.com/archive/1.2.6/
That uses the “gmcs” c# compiler to target the 2.0 .Net runtime ?
http://www.mono-project.com/CSharp_Compiler

The current Stable release of Mono is 1.9
“Mono 1.9 is our last release before Mono turns 2.0, it is a stable release and an update to Mono 1.2.6 in the Mono 1.2 series, it is a bug fix release for all the supported components, but also includes updates on the 2.0 and 3.5 stacks.”
This version uses a “new” c# compiler that targets the 3.5 .Net runtime?

http://www.go-mono.com/archive/1.9/

Example:
The new c# 3.0 specification for Automatic property declarations will not compile in the current Unity Mono version

class Something {
    public string something { get; set;} // Automatic property...
 }

source: Auto-Implemented Properties - C# | Microsoft Learn

Cheers,
Tobias