2003-11-25 05:44:12 +03:00
|
|
|
//
|
|
|
|
// Mono.ASPNET.Tools.StateServer
|
|
|
|
//
|
|
|
|
// Author(s):
|
|
|
|
// Jackson Harper (jackson@ximian.com)
|
|
|
|
//
|
|
|
|
// (C) 2003 Novell, Inc (http://www.novell.com)
|
|
|
|
//
|
|
|
|
|
|
|
|
using System;
|
2005-06-17 22:15:54 +04:00
|
|
|
using System.IO;
|
|
|
|
using System.Reflection;
|
2003-11-25 05:44:12 +03:00
|
|
|
using System.Runtime.Remoting;
|
|
|
|
|
|
|
|
namespace Mono.ASPNET.Tools {
|
|
|
|
|
2005-06-17 22:15:54 +04:00
|
|
|
public class StateServer {
|
|
|
|
|
|
|
|
private static string ServerName {
|
|
|
|
get {
|
|
|
|
return Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly ().CodeBase);
|
|
|
|
}
|
|
|
|
}
|
2003-11-25 05:44:12 +03:00
|
|
|
|
2005-06-17 22:15:54 +04:00
|
|
|
private static string configurationfile;
|
|
|
|
private static string ConfigurationFileName {
|
|
|
|
get {
|
|
|
|
if (configurationfile == null) {
|
|
|
|
configurationfile = Assembly.GetEntryAssembly ().CodeBase + ".config";
|
|
|
|
if (configurationfile.StartsWith("file://"))
|
|
|
|
configurationfile = configurationfile.Substring(7);
|
|
|
|
}
|
|
|
|
return configurationfile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void ShowUsage()
|
|
|
|
{
|
|
|
|
Console.WriteLine(@"ERROR: {0} doesn't recognize any command line arguments!!!
|
|
|
|
|
|
|
|
Usage is:
|
|
|
|
{0}
|
|
|
|
|
|
|
|
It loads the remoting configuration file (will try from {1})
|
|
|
|
and works until <Enter> is pressed.
|
|
|
|
", ServerName, ConfigurationFileName);
|
|
|
|
}
|
2003-11-25 05:44:12 +03:00
|
|
|
|
2005-06-17 22:15:54 +04:00
|
|
|
private static void ShowVerboseConfigurationInfo(string filename)
|
|
|
|
{
|
|
|
|
Console.WriteLine("Loaded configuration from {0} that contains", filename);
|
|
|
|
Console.WriteLine("=============================================");
|
|
|
|
try {
|
|
|
|
StreamReader sr = new StreamReader(filename);
|
|
|
|
Console.WriteLine(sr.ReadToEnd());
|
|
|
|
sr.Close();
|
|
|
|
} catch (Exception ex) {
|
|
|
|
Console.WriteLine("ERROR reading configuration file:\n" + ex.ToString());
|
|
|
|
}
|
|
|
|
Console.WriteLine("=============================================");
|
|
|
|
}
|
|
|
|
|
|
|
|
[STAThread]
|
|
|
|
public static void Main (string [] args)
|
|
|
|
{
|
|
|
|
if (args.Length == 0) {
|
2011-04-14 05:07:22 +04:00
|
|
|
RemotingConfiguration.Configure (ConfigurationFileName, false);
|
2005-06-17 22:15:54 +04:00
|
|
|
ShowVerboseConfigurationInfo(ConfigurationFileName);
|
|
|
|
Console.Write("Press <Enter> to stop...");
|
|
|
|
Console.ReadLine ();
|
|
|
|
} else {
|
|
|
|
ShowUsage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2003-11-25 05:44:12 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|