public static MonoRuntimeInfo FromCurrentRuntime()
        {
            // Get the current mono version
            Type t = Type.GetType("Mono.Runtime");

            if (t == null)
            {
                return(null);
            }

            MonoRuntimeInfo rt = new MonoRuntimeInfo();

            // Since Mono 3.0.5/ee035e3eb463816a9590b09f65842503640c6337 GetDisplayName is public
            string ver = (string)t.InvokeMember("GetDisplayName", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, null, null, null);

            //not sure which version this old scheme applies to
            int i = ver.IndexOf("/branches/mono-");

            if (i != -1)
            {
                i += 15;
                int j = ver.IndexOf('/', i);
                if (j != -1)
                {
                    rt.monoVersion = ver.Substring(i, j - i).Replace('-', '.');
                }
            }
            else if (ver.StartsWith("/trunk/mono "))
            {
                rt.monoVersion = "Trunk";
            }

            if (rt.monoVersion == "Unknown")
            {
                i = ver.IndexOf(' ');
                //this schme applies to mono 2.6.3+
                if (ver.Length > i && ver[i + 1] == '(')
                {
                    rt.monoVersion = ver.Substring(0, i);
                }
                //not sure how old this scheme is
                else
                {
                    rt.monoVersion = ver.Substring(i + 1);
                }
            }

            //Pull up assemblies from the installed mono system.
            rt.prefix = PathUp(typeof(int).Assembly.Location, 4);
            if (rt.prefix == null)
            {
                throw new SystemException("Could not detect Mono prefix");
            }

            rt.SetupPkgconfigPaths(Environment.GetEnvironmentVariable("PKG_CONFIG_PATH"),
                                   Environment.GetEnvironmentVariable("PKG_CONFIG_LIBDIR"));

            foreach (string varName in new [] { "PATH", "MONO_GAC_PREFIX", "XBUILD_FRAMEWORK_FOLDERS_PATH" })
            {
                rt.envVars [varName] = Environment.GetEnvironmentVariable(varName);
            }

            rt.IsRunning      = true;
            rt.initialized    = true;
            rt.isValidRuntime = true;

            return(rt);
        }
		public static MonoRuntimeInfo FromCurrentRuntime ()
		{
			// Get the current mono version
			Type t = Type.GetType ("Mono.Runtime");
			if (t == null)
				return null;
			
			MonoRuntimeInfo rt = new MonoRuntimeInfo ();
			
			// Since Mono 3.0.5/ee035e3eb463816a9590b09f65842503640c6337 GetDisplayName is public
			string ver = (string) t.InvokeMember ("GetDisplayName", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, null, null, null);
			
			//not sure which version this old scheme applies to
			int i = ver.IndexOf ("/branches/mono-");
			if (i != -1) {
				i += 15;
				int j = ver.IndexOf ('/', i);
				if (j != -1)
					rt.monoVersion = ver.Substring (i, j - i).Replace ('-','.');
			} else if (ver.StartsWith ("/trunk/mono ")) {
				rt.monoVersion = "Trunk";
			}
			
			if (rt.monoVersion == "Unknown") {
				i = ver.IndexOf (' ');
				//this schme applies to mono 2.6.3+
				if (ver.Length > i && ver[i+1] == '(')
					rt.monoVersion = ver.Substring (0, i);
				//not sure how old this scheme is
				else
					rt.monoVersion = ver.Substring (i+1);
			}

			//Pull up assemblies from the installed mono system.
			rt.prefix = PathUp (typeof (int).Assembly.Location, 4);
			if (rt.prefix == null)
				throw new SystemException ("Could not detect Mono prefix");
			
			rt.SetupPkgconfigPaths (Environment.GetEnvironmentVariable ("PKG_CONFIG_PATH"),
			                        Environment.GetEnvironmentVariable ("PKG_CONFIG_LIBDIR"));
			
			foreach (string varName in new [] { "PATH", "MONO_GAC_PREFIX", "XBUILD_FRAMEWORK_FOLDERS_PATH" }) {
				rt.envVars [varName] = Environment.GetEnvironmentVariable (varName);
			}
			
			rt.IsRunning = true;
			rt.initialized = true;
			rt.isValidRuntime = true;
			
			return rt;
		}