RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Using .NET 3.5 Features with RunUO

Ánheledir

Wanderer
Using .NET 3.5 Features with RunUO

First, before I show you the tricky part there are some questions you should ask yourself:

  • Are you willing to recompile the core? (Remember: You will not get support in case you have some script-problems and using a modified core even though your problem has nothing to do with it!)
  • Are you sure you have installed the Microsoft .NET Framework 3.5 both on your Development-Server and your Productive-Server?
  • Do you know what LINQ is or do you really need other (new) features of C# or VB.NET 3.0?
  • Do you know what a Dictionary-Object is and what it is used for?
  • Are you a geek?

In case you have answered one or more times with "no", leave this thread. Now. Also I do not recommend to do any core-changes you don't understand! I'm neither a teacher nor a debugger: If you have some strange problems with the following changes -> revert them or try to understand what the .NET-Compiler tries to tell you.... ;)


Sooo.... you are still with me? Excitingly reading how to use those cool new features like LINQ, anonymous classes, extensions, add-ins, ....?? Here is all the magic:

First: Open ScriptCompiler.cs and search for this line:
Code:
using ( CSharpCodeProvider provider = new CSharpCodeProvider() )

Second: Replace this line with the following:
Code:
var providerOptions = new Dictionary<string, string>();
providerOptions.Add( "CompilerVersion", "v3.5" );
using ( CSharpCodeProvider provider = new CSharpCodeProvider( providerOptions ) )

Repeat those steps for the VBCodeProvider(), too.

Yep, thats all... have fun :p

--Anheledir
 

Erica

Knight
I run a a server RunUO 2.0 RC2 and my computer has 3.5 net and it still runs the server with no core modification. So 3.5 net does work with RunUO 2.0 RC2.
 

Ánheledir

Wanderer
Erica;750752 said:
I run a a server RunUO 2.0 RC2 and my computer has 3.5 net and it still runs the server with no core modification. So 3.5 net does work with RunUO 2.0 RC2.

OK, you have no clue what this patch is doing, do you? :p

You can obviously run RunUO 2.0 on .NET 3.5 'cause 3.5 doesn't have a new CRL. The .NET Core (CRL) is still on version 2.0. Then .NET 3.0 had a new version of C# and some new namespaces for WPF, WCF and WF, but it's only build around the 2.0 CRL. And now there is .NET 3.5 - and the biggest new feature is LINQ. But: It is using the 2.0 CRL, too.

So... in case you have installed .NET 3.0 or 3.5 you must have .NET 2.0 also. Because of that there is no problem running RunUO with the new Framework. But in case you want to use some of the new features from .NET 3.0 or 3.5, you must tell the internal script-Compiler from RunUO to compile against those new namespaces. And thats exactly what my little patch is doing.

Example 1:
Without this patch and only .NET 2.0 you have to write the following:

Code:
private bool _someProperty;
public bool SomeProperty {
get { return _someProperty; }
set { _someProperty = value; }
}

With this patch and .NET 3.5 you can shorten this to:
Code:
public bool SomeProperty { get; set; }


Example 2:
Without this patch and only .NET 2.0 you have to write the following:

Code:
Cloak c = new Cloak();
c.IsArcane = true;
c.MaxArcaneCharges = 10;
c.CurArcaneCharges = 10;

With this patch and .NET 3.5 you can simply write:
Code:
var c = new Cloak(IsArcane = true, MaxArcaneCharges = 10, CurArcaneCharges = 10);

These are only two small features of the new Framework you cannot use without this patch (RunUO would throw a exception on compile) and there are many more - but this is no place to advertise the new framework or to give lessons in LINQ :eek:
 

Erica

Knight
Ánheledir;750757 said:
OK, you have no clue what this patch is doing, do you? :p

You can obviously run RunUO 2.0 on .NET 3.5 'cause 3.5 doesn't have a new CRL. The .NET Core (CRL) is still on version 2.0. Then .NET 3.0 had a new version of C# and some new namespaces for WPF, WCF and WF, but it's only build around the 2.0 CRL. And now there is .NET 3.5 - and the biggest new feature is LINQ. But: It is using the 2.0 CRL, too.

So... in case you have installed .NET 3.0 or 3.5 you must have .NET 2.0 also. Because of that there is no problem running RunUO with the new Framework. But in case you want to use some of the new features from .NET 3.0 or 3.5, you must tell the internal script-Compiler from RunUO to compile against those new namespaces. And thats exactly what my little patch is doing.

Example 1:
Without this patch and only .NET 2.0 you have to write the following:

Code:
private bool _someProperty;
public bool SomeProperty {
get { return _someProperty; }
set { _someProperty = value; }
}

With this patch and .NET 3.5 you can shorten this to:
Code:
public bool SomeProperty { get; set; }


Example 2:
Without this patch and only .NET 2.0 you have to write the following:

Code:
Cloak c = new Cloak();
c.IsArcane = true;
c.MaxArcaneCharges = 10;
c.CurArcaneCharges = 10;

With this patch and .NET 3.5 you can simply write:
Code:
var c = new Cloak(IsArcane = true, MaxArcaneCharges = 10, CurArcaneCharges = 10);

These are only two small features of the new Framework you cannot use without this patch (RunUO would throw a exception on compile) and there are many more - but this is no place to advertise the new framework or to give lessons in LINQ :eek:

Ah i see i misunderstood you hehe .
 

ETsCat

Sorceror
OK sounds goodBut

Ánheledir;750511 said:
First, before I show you the tricky part there are some questions you should ask yourself:

  • Are you willing to recompile the core? (Remember: You will not get support in case you have some script-problems and using a modified core even though your problem has nothing to do with it!)
  • Are you sure you have installed the Microsoft .NET Framework 3.5 both on your Development-Server and your Productive-Server?
  • Do you know what LINQ is or do you really need other (new) features of C# or VB.NET 3.0?
  • Do you know what a Dictionary-Object is and what it is used for?
  • Are you a geek?

In case you have answered one or more times with "no", leave this thread. Now. Also I do not recommend to do any core-changes you don't understand! I'm neither a teacher nor a debugger: If you have some strange problems with the following changes -> revert them or try to understand what the .NET-Compiler tries to tell you.... ;)


Sooo.... you are still with me? Excitingly reading how to use those cool new features like LINQ, anonymous classes, extensions, add-ins, ....?? Here is all the magic:

First: Open ScriptCompiler.cs and search for this line:
Code:
using ( CSharpCodeProvider provider = new CSharpCodeProvider() )

Second: Replace this line with the following:
Code:
var providerOptions = new Dictionary<string, string>();
providerOptions.Add( "CompilerVersion", "v3.5" );
using ( CSharpCodeProvider provider = new CSharpCodeProvider( providerOptions ) )

Repeat those steps for the VBCodeProvider(), too.

Yep, thats all... have fun :p

--Anheledir

Where In Hades is the "ScriptCompiler.cs " ?
I do a Search but it dont show anything exxcept Not Found.
 

CEO

Sorceror
You must not have the full RunUO 2.0 with server sources or you're looking in the Scripts directory. ScriptCompiler.cs is in the Server directory where the RunUO source is.
 
i followed your guies but i am getting an error when importing System.Linq or Systm.Data.Linq.... Any ideas? when RunUO starts it says its running framework 2.0 even though i compile with 3.5? is that normal?
 
I managed to get it working by adding the following line to Assemablies.cfs in the Data Folder

System.Core.cll

in addition to the steps posted above. This dll is required to load the Linq part of 3.5 framework and maybe more.
 

fwiffo

Sorceror
this is really interesting, since I'm not programmer, but I'm starting to understand and learn better c# I think I should get a grasp of the new features of new .net, there are really a lot of changes and I think that stagnating in old 2.0 is bad after only having read of those two small changes that can make lot of things simple even to write down.

Thanks for sharing!
 

fwiffo

Sorceror
-.- I was just saying that it's interesting to know also mods made to language, since I'm stagnated to old grammar and typing
 
Top