在Linux vps(CentOS 5)上运行C#或VB或asp代码的小片段

I need to run a small snippet of code (below) on my linux vps to generate a string based on a specific id number. I'm not very experienced with PHP but I have tried coding algorithm in PHP but I always get a different result than the c# code - most likely due to the way the Randomize or Rnd functions operate.

Is mono a valid solution for something this small? What is involved in the implementation. Any information is useful, I can do more research but I just need verification that I'm not wasting my time trying to get this working on Linux. Anyone have any experience using Mono for small scripts?

EDIT I'm very interested in anyone with experience in the implementation of mono with something this small.

The code for c# is below. Before this runs, I will make a call to my database to retrieve number stored in the unqiueid string variable. After this snippet runs, I'll have code to write the unlockcode variable to the database.

var rnum = Microsoft.VisualBasic.VBMath.Rnd(-1);
var seed = 2 * uniqueid.AsInt();
Microsoft.VisualBasic.VBMath.Randomize(seed);
for (int i = 1; i <= 6; i++)
{
   unlockcode = unlockcode + Convert.ToChar((int)((26) * Microsoft.VisualBasic.VBMath.Rnd() + 1 + 64));
}

I'm a litte puzzled about your question.
The limited size of your application is no reason "not" to use Mono.

However, when you are targetting Linux you should avoid things that are Windows specific.
For example, you can't run WPF applications on Linux.

In theory you can just compile your code and run it on Linux with Mono,
but you are using classes from Microsoft.VisualBasic. I haven't checked if it's available on Mono or not, but even if it is, there's no need to use it:

var unlockCode = 0;
var random = new Random(Convert.ToInt32(uniqueId));
var randomNumber = random.Next();
for (int i = 1; i < 6; i++)
{
    unlockCode += Convert.ToChar((int)((26) * random.Next() + 1 + 64));
}

Use System.Random instead of Microsoft.VisualBasic.VBMath.Randomize, that's one less dependency to worry about.

I should also note that when you compile this on Windows using let's say Visual Studio for example,
there is no need for you to recompile it in order to use it on Linux, just copy the compiled assembly (exe) deploy it on Linux and execute it with Mono.

Vice Versa, if you compile the application on Linux using the mono csharp compiler you can simply copy it to your Windows machine and execute it with .NET (or Mono)

If you have compiled an application on Windows and want to know if it uses anything that is not available on Linux/Mono, use the MoMa tool: http://www.mono-project.com/MoMA

It will tell you what issues you will encounter if you run the application on Linux/Mono.

Update: About your comments

It seems a bit silly to run Mono just to run 7 lines legacy c# code

There is nothing silly about it... sure it takes up some disk space but it's not a process that runs continuously in the background or anything. The Mono runtime is used when you execute your application and stops when there is no other Mono/.NET app active. The same could be said about Python applications or even command line PHP applications. There's no harm in having Mono on your system, I wouldn't worry about it.