Beispiel #1
0
            public async Task HostMachine()
            {
                EmbedBuilder embed = Util.Embed.GetDefaultEmbed(Context, "Runtime Information", "Details of the bot and OS", new Color(194, 24, 91));

                embed.Fields = new List <EmbedFieldBuilder>
                {
                    new()
                    {
                        Name     = ".NET Installation",
                        Value    = RuntimeInformation.FrameworkDescription + "\n" + RuntimeInformation.ProcessArchitecture,
                        IsInline = true
                    },
                    new()
                    {
                        Name     = "OS Description",
                        Value    = RuntimeInformation.OSDescription + "\n" + RuntimeInformation.OSArchitecture,
                        IsInline = true
                    },
                    new()
                    {
                        Name     = "Runtime Environment Version",
                        Value    = RuntimeEnvironment.GetSystemVersion(),
                        IsInline = true
                    }
                };

                await ReplyAsync("", false, embed.Build());
            }
        }
Beispiel #2
0
        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            base.Uninstall(savedState);
            string targetDir = this.Context.Parameters["TARGETDIR"].ToString();

            string runtimedir = Path.GetFullPath(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), @"../.."));
            //string net_base = Directory.GetParent(runtimedir).FullName;
            string to_exec = String.Concat(runtimedir, "\\Framework\\", RuntimeEnvironment.GetSystemVersion(), @"\regasm.exe");

            System.Diagnostics.Process proc = new System.Diagnostics.Process();

            proc.EnableRaisingEvents              = false;
            proc.StartInfo.FileName               = "cmd.exe";
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardInput  = true;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError  = true;
            proc.StartInfo.CreateNoWindow         = true;


            proc.Start();

            proc.StandardInput.WriteLine(to_exec + " \"" + targetDir + "\\UofShellExt.dll\" /u");

            //  proc.StandardInput.WriteLine(to_exec + " \"C:\\Program Files\\UOF Working Group\\UOFTranslator4.0\\UofShellExt.dll\" /u");


            proc.StandardInput.WriteLine("exit");
        }
        public static void Main(string[] Arguments)
        {
            try
            {
                SetConsoleTitle("Maelstrom World of Warcraft Server Emulator v1.0");

                Console.WriteLine("Maelstrom World of Warcraft Server Emulator version 1.0");
                Console.WriteLine("Copyright (c) 2004 Team Maelstrom\n");

                Console.WriteLine(".NET Common Language Runtime version {0}", RuntimeEnvironment.GetSystemVersion());

                Initialize();

                Run(Arguments);

                //Place the main process thread in a suspended state.
                Thread.Sleep(System.Threading.Timeout.Infinite);
            }
            catch (Exception e)
            {
                Console.WriteLine("-------------------------------------------------------------------------------");

                Console.WriteLine("\nThere has been a critical server error:\n");
                Console.WriteLine(e.Message);

                //Log the error here...
            }
            finally
            {
                //Shutdown cores...
                Shutdown();
            }
        }
Beispiel #4
0
        private static int RunAnalysis(AnalyzeDotNetOptions options)
        {
            // get .NET FW directory
            Console.WriteLine(RuntimeEnvironment.GetSystemVersion());
            var dotNetInstallDirectory = RuntimeEnvironment.GetRuntimeDirectory();

            Console.WriteLine($"Detect .NET FW: {dotNetInstallDirectory}");

            // Copy .NET to Temp directory
            if (!Directory.Exists(options.TempDirectory))
            {
                Directory.CreateDirectory(options.TempDirectory);
            }

            CopyAssemblies(dotNetInstallDirectory, options.TempDirectory);
            CopyAssemblies(Path.Combine(dotNetInstallDirectory, "WPF"), options.TempDirectory);

            // Copy files from input directory to Temp
            if (!String.IsNullOrEmpty(options.Directory))
            {
                CopyAssemblies(options.Directory, options.TempDirectory);
            }

            return(RunAnalysis(options.TempDirectory, options.EntryPoint, options.Output));
        }
        private static void RegAsm(string parameters)
        {
            // RuntimeEnvironment.GetRuntimeDirectory() returns something like
            // C:\Windows\Microsoft.NET\Framework64\v2.0.50727\
            // But we only want the "C:\Windows\Microsoft.NET" part
            string net_base = Path.GetFullPath(Path.Combine(
                                                   RuntimeEnvironment.GetRuntimeDirectory(), @"..\.."));

            // Create paths to 32bit and 64bit versions of regasm.exe
            string[] to_exec = new[]
            {
                string.Concat(net_base, "\\Framework\\",
                              RuntimeEnvironment.GetSystemVersion(), "\\regasm.exe"),
                string.Concat(net_base, "\\Framework64\\",
                              RuntimeEnvironment.GetSystemVersion(), "\\regasm.exe")
            };
            // Get the path to the plugin's location
            var dll_path = Assembly.GetExecutingAssembly().Location;

            foreach (string path in to_exec)
            {
                // Skip the executables that do not exist; This most likely happens on
                // a 32bit machine when processing the path to 64bit regasm
                if (!File.Exists(path))
                {
                    continue;
                }
                // Build the argument string
                string args = string.Format("\"{0}\" {1}", dll_path, parameters);
                // Launch the regasm.exe process
                LaunchProcess(path, args);
            }
        }
    static void Main()
    {
        //<snippet2>
        // Show whether the EXE assembly was loaded from the GAC or from a private subdirectory.
        Assembly assem = typeof(App).Assembly;

        Console.WriteLine("Did the {0} assembly load from the GAC? {1}",
                          assem, RuntimeEnvironment.FromGlobalAccessCache(assem));
        //</snippet2>

        //<snippet3>
        // Show the path where the CLR was loaded from.
        Console.WriteLine("Runtime directory: {0}", RuntimeEnvironment.GetRuntimeDirectory());
        //</snippet3>

        //<snippet4>
        // Show the CLR's version number.
        Console.WriteLine("System version: {0}", RuntimeEnvironment.GetSystemVersion());
        //</snippet4>

        //<snippet5>
        // Show the path of the machine's configuration file.
        Console.WriteLine("System configuration file: {0}", RuntimeEnvironment.SystemConfigurationFile);
        //</snippet5>
    }
Beispiel #7
0
        private static void RegAsm(string parameters)
        {
            var deployment_directory_partial = Path.GetFullPath(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), @"..\.."));
            var target_regasm_path_array     = new[]
            {
                string.Concat(deployment_directory_partial, "\\Framework\\", RuntimeEnvironment.GetSystemVersion(), "\\regasm.exe"),
                string.Concat(deployment_directory_partial, "\\Framework64\\", RuntimeEnvironment.GetSystemVersion(), "\\regasm.exe")
            };
            var pathToCompiledCode = Assembly.GetExecutingAssembly().Location;

            foreach (var target_regasm_path in target_regasm_path_array)
            {
                if (!File.Exists(target_regasm_path))
                {
                    continue;
                }
                var process = new Process
                {
                    StartInfo =
                    {
                        CreateNoWindow  = true,
                        ErrorDialog     = false,
                        UseShellExecute = false,
                        FileName        = target_regasm_path,
                        Arguments       = string.Format("\"{0}\" {1}", pathToCompiledCode, parameters)
                    }
                };
                using (process)
                {
                    process.Start();
                    process.WaitForExit();
                }
            }
        }
Beispiel #8
0
        public int[] EnumDomains()
        {
            int[] getIds = new int[1024];
            int   count  = 0;

            while (true)
            {
                count = _enumDomains(RuntimeEnvironment.GetSystemVersion(),
                                     GetType().Assembly.Location,
                                     typeof(AppDomainBridge).FullName,
                                     "GetCurrentDomainId",
                                     getIds,
                                     getIds.Length);
                if (count == -1)
                {
                    return(null);
                }
                if (count < getIds.Length)
                {
                    break;
                }
                getIds = new int[count];
            }

            int[] ids = new int[count];
            for (int i = 0; i < ids.Length; i++)
            {
                ids[i] = getIds[i];
            }
            return(ids);
        }
Beispiel #9
0
        internal static EnvironmentData Create(Verbosity verbosity)
        {
            var result = new EnvironmentData {
                CommandLine        = Environment.CommandLine,
                FrameworkVersion   = RuntimeEnvironment.GetSystemVersion(),
                MachineName        = Environment.MachineName,
                UserDomainName     = Environment.UserDomainName,
                UserInteractive    = Environment.UserInteractive,
                UserName           = Environment.UserName,
                SystemDirectory    = Environment.SystemDirectory,
                OSVersion          = Environment.OSVersion,
                Version            = Environment.Version,
                HasShutdownStarted = Environment.HasShutdownStarted,
                ProcessorCount     = Environment.ProcessorCount,
                IsMono             = Platform.Current.IsMono,
            };

            if (verbosity > Verbosity.Normal)
            {
                CaptureEnvironmentVariables(result);
                CaptureLogicalDrives(result);
            }

            return(result);
        }
Beispiel #10
0
    public static int Main()
    {
        var re = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID);

        uint buffer_size = 260;

        re.GetVersionString(IntPtr.Zero, ref buffer_size);

        var buffer = Marshal.AllocCoTaskMem((int)buffer_size);

        re.GetVersionString(buffer, ref buffer_size);

        string version = Marshal.PtrToStringUni(buffer);

        Marshal.FreeCoTaskMem(buffer);

        if (version != RuntimeEnvironment.GetSystemVersion())
        {
            Console.WriteLine("ICLRRuntimeInfo version is {0}", version);
            Console.WriteLine("RuntimeEnvironment.GetSystemVersion is {0}", RuntimeEnvironment.GetSystemVersion());
            return(1);
        }

        return(0);
    }
        public void OutputRuntimeInfo()
        {
            var runtimeInformationType = AccessTools2.TypeByName("System.Runtime.InteropServices.RuntimeInformation");
            var executingAssembly      = Assembly.GetExecutingAssembly();

            TestTools.Log("Environment.OSVersion: " + Environment.OSVersion);
            TestTools.Log("RuntimeInformation.OSDescription: " + GetProperty(runtimeInformationType, "OSDescription"));

            TestTools.Log("IntPtr.Size: " + IntPtr.Size);
            TestTools.Log("Environment.Is64BitProcess: " + GetProperty(typeof(Environment), "Is64BitProcess"));
            TestTools.Log("Environment.Is64BitOperatingSystem: " + GetProperty(typeof(Environment), "Is64BitOperatingSystem"));
            TestTools.Log("RuntimeInformation.ProcessArchitecture: " + GetProperty(runtimeInformationType, "ProcessArchitecture"));
            TestTools.Log("RuntimeInformation.OSArchitecture: " + GetProperty(runtimeInformationType, "OSArchitecture"));

            TestTools.Log("RuntimeInformation.FrameworkDescription: " + GetProperty(runtimeInformationType, "FrameworkDescription"));
            TestTools.Log("Mono.Runtime.DisplayName: " + CallGetter(Type.GetType("Mono.Runtime"), "GetDisplayName"));
            TestTools.Log("RuntimeEnvironment.RuntimeDirectory: " + RuntimeEnvironment.GetRuntimeDirectory());
            TestTools.Log("RuntimeEnvironment.SystemVersion: " + RuntimeEnvironment.GetSystemVersion());
            TestTools.Log("Environment.Version: " + Environment.Version);

            TestTools.Log("Core Assembly: " + typeof(object).Assembly);
            TestTools.Log("Executing Assembly's ImageRuntimeVersion: " + executingAssembly.ImageRuntimeVersion);
            TestTools.Log("Executing Assembly's TargetFrameworkAttribute: " + (executingAssembly.GetCustomAttributes(true)
                                                                               .Where(attr => attr.GetType().Name is "TargetFrameworkAttribute")
                                                                               .Select(attr => Traverse2.Create(attr).Property("FrameworkName").GetValue <string>())
                                                                               .FirstOrDefault() ?? "null"));
        }
Beispiel #12
0
        public ActionResult SystemInfo()
        {
            var model = new SystemInfoModel();

            model.NopVersion = NopVersion.CurrentVersion;
            try
            {
                model.OperatingSystem = Environment.OSVersion.VersionString;
            }
            catch (Exception) { }
            try
            {
                model.AspNetInfo = RuntimeEnvironment.GetSystemVersion();
            }
            catch (Exception) { }
            try
            {
                model.IsFullTrust = AppDomain.CurrentDomain.IsFullyTrusted.ToString();
            }
            catch (Exception) { }
            model.ServerTimeZone  = TimeZone.CurrentTimeZone.StandardName;
            model.ServerLocalTime = DateTime.Now;
            model.UtcTime         = DateTime.UtcNow;
            //Environment.GetEnvironmentVariable("USERNAME");
            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                model.LoadedAssemblies.Add(new SystemInfoModel.LoadedAssembly()
                {
                    FullName = assembly.FullName,
                    //we cannot use Location property in medium trust
                    //Location = assembly.Location
                });
            }
            return(View(model));
        }
Beispiel #13
0
    private static void Main(string[] args)
    {
        try
        {
            string[] strArray = RuntimeEnvironment.GetSystemVersion().Trim(new char[] { 'v' }).Split(new char[] { '.' });
            if (strArray.Length > 0)
            {
                int num;
                int.TryParse(strArray[0], out num);
                if (num < 2)
                {
                    MessageBox.Show("需安装 .NET Framework 2.0 或以上版本。");
                    return;
                }
            }
        }
        catch
        {
        }
        SingletonApplication instance = SingletonApplication.GetInstance(Application.ProductVersion, args);

        if (instance.Register())
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Mainform implement = Mainform.instance;
            instance.AddSingletonFormListener(implement);
            implement.CommandRun(args);
            Application.Run(implement);
        }
    }
Beispiel #14
0
        public static void Hook()
        {
            bool isNetFramework4 = RuntimeEnvironment.GetSystemVersion()[1] == '4';

            IntPtr jitLibrary = LoadLibrary(isNetFramework4 ? "clrjit.dll" : "mscorjit.dll");

            getJit getJitDelegate = (getJit)Marshal.GetDelegateForFunctionPointer(GetProcAddress(jitLibrary, "getJit"), typeof(getJit));

            IntPtr getJitAddress = *getJitDelegate();

            IntPtr originalAddress = *(IntPtr *)getJitAddress;

            //originalDelegate = (Data.compileMethod)Marshal.GetDelegateForFunctionPointer(getJitAddress, typeof(Data.compileMethod));
            handler = HookHandler;

            originalDelegate =
                (Data.compileMethod)Marshal.GetDelegateForFunctionPointer(originalAddress, typeof(Data.compileMethod));

            RuntimeHelpers.PrepareDelegate(originalDelegate);
            RuntimeHelpers.PrepareDelegate(handler);

            uint oldPl;

            VirtualProtect(getJitAddress, (uint)IntPtr.Size, 0x40, out oldPl);
            Marshal.WriteIntPtr(getJitAddress, Marshal.GetFunctionPointerForDelegate(handler));
            VirtualProtect(getJitAddress, (uint)IntPtr.Size, oldPl, out oldPl);
        }
Beispiel #15
0
        public ActionResult SystemInfo()
        {
            var model = new SystemInfoModel();

            model.NopVersion = NopVersion.CurrentVersion;
            try
            {
                model.OperatingSystem = Environment.OSVersion.VersionString;
            }
            catch (Exception) { }
            try
            {
                model.AspNetInfo = RuntimeEnvironment.GetSystemVersion();
            }
            catch (Exception) { }
            try
            {
                model.IsFullTrust = AppDomain.CurrentDomain.IsFullyTrusted.ToString();
            }
            catch (Exception) { }
            model.ServerTimeZone  = TimeZone.CurrentTimeZone.StandardName;
            model.ServerLocalTime = DateTime.Now;
            model.UtcTime         = DateTime.UtcNow;
            //Environment.GetEnvironmentVariable("USERNAME");
            return(View(model));
        }
        private static string ChooseCompilerVersion()
        {
            var runtime = RuntimeEnvironment.GetSystemVersion();

            var runtimeSubstring = runtime.Substring(0, "vX.X".Length);

            return(runtimeSubstring.Equals("v2.0", StringComparison.InvariantCultureIgnoreCase) ? "v3.5" : "v4.0");
        }
Beispiel #17
0
 public void Execute()
 {
     //
     // System.Runtime.InteropServices.RuntimeEnvironmentクラスを利用する事で
     // .NETのランタイムパスなどを取得することができる。
     //
     Output.WriteLine("Runtime PATH:{0}", RuntimeEnvironment.GetRuntimeDirectory());
     Output.WriteLine("System Version:{0}", RuntimeEnvironment.GetSystemVersion());
 }
Beispiel #18
0
        public static string GetRuntimeFramework()
        {
#if NET451 || NET452 || NET46 || NET461 || NET462 || NET47
            return(RuntimeEnvironment.GetSystemVersion());
#else
            // Only available on .NET Framework starting with 4.7.1 (also netstandard1.1 and later)
            return(RuntimeInformation.FrameworkDescription);
#endif
        }
Beispiel #19
0
        public async Task <Result> Get()
        {
            var version = await _appSettingService.Get("Global.AssetVersion");

            var result = new SystemInfoResult()
            {
                Version         = version,
                ServerTimeZone  = TimeZoneInfo.Local.StandardName,
                ServerLocalTime = DateTime.Now,
                UtcTime         = DateTime.UtcNow,
                HttpHost        = _httpContextAccessor.HttpContext.Request.Headers[HeaderNames.Host],
            };

            //ensure no exception is thrown
            try
            {
                result.OperatingSystem = Environment.OSVersion.VersionString;
                result.AspNetInfo      = RuntimeEnvironment.GetSystemVersion();
                result.IsFullTrust     = AppDomain.CurrentDomain.IsFullyTrusted.ToString();
            }
            catch { }

            //foreach (var header in _httpContextAccessor.HttpContext.Request.Headers)
            //{
            //    result.Headers.Add(new SystemInfoResult.HeaderModel
            //    {
            //        Name = header.Key,
            //        Value = header.Value
            //    });
            //}

            //foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            //{
            //    var loadedAssemblyModel = new SystemInfoResult.LoadedAssembly
            //    {
            //        FullName = assembly.FullName
            //    };

            //    //ensure no exception is thrown
            //    try
            //    {
            //        loadedAssemblyModel.Location = assembly.IsDynamic ? null : assembly.Location;
            //        loadedAssemblyModel.IsDebug = assembly.GetCustomAttributes(typeof(DebuggableAttribute), false)
            //            .FirstOrDefault() is DebuggableAttribute attribute && attribute.IsJITOptimizerDisabled;

            //        //https://stackoverflow.com/questions/2050396/getting-the-date-of-a-net-assembly
            //        //we use a simple method because the more Jeff Atwood's solution doesn't work anymore
            //        //more info at https://blog.codinghorror.com/determining-build-date-the-hard-way/
            //        loadedAssemblyModel.BuildDate = assembly.IsDynamic ? null : (DateTime?)TimeZoneInfo.ConvertTimeFromUtc(System.IO.File.GetLastWriteTimeUtc(assembly.Location), TimeZoneInfo.Local);

            //    }
            //    catch { }
            //    result.LoadedAssemblies.Add(loadedAssemblyModel);
            //}

            return(Result.Ok(result));
        }
Beispiel #20
0
        /// <summary>
        /// Prepare system info model
        /// </summary>
        /// <param name="model">System info model</param>
        /// <returns>System info model</returns>
        public virtual SystemInfoModel PrepareSystemInfoModel(SystemInfoModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            model.NopVersion      = NopVersion.CurrentVersion;
            model.ServerTimeZone  = TimeZoneInfo.Local.StandardName;
            model.ServerLocalTime = DateTime.Now;
            model.UtcTime         = DateTime.UtcNow;
            model.CurrentUserTime = _dateTimeHelper.ConvertToUserTime(DateTime.Now);
            model.HttpHost        = _httpContextAccessor.HttpContext.Request.Headers[HeaderNames.Host];

            //ensure no exception is thrown
            try
            {
                model.OperatingSystem = Environment.OSVersion.VersionString;
                model.AspNetInfo      = RuntimeEnvironment.GetSystemVersion();
                model.IsFullTrust     = AppDomain.CurrentDomain.IsFullyTrusted.ToString();
            }
            catch { }

            foreach (var header in _httpContextAccessor.HttpContext.Request.Headers)
            {
                model.Headers.Add(new SystemInfoModel.HeaderModel
                {
                    Name  = header.Key,
                    Value = header.Value
                });
            }

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                var loadedAssemblyModel = new SystemInfoModel.LoadedAssembly
                {
                    FullName = assembly.FullName
                };

                //ensure no exception is thrown
                try
                {
                    loadedAssemblyModel.Location = assembly.IsDynamic ? null : assembly.Location;
                    loadedAssemblyModel.IsDebug  = assembly.GetCustomAttributes(typeof(DebuggableAttribute), false)
                                                   .FirstOrDefault() is DebuggableAttribute attribute && attribute.IsJITOptimizerDisabled;

                    //https://stackoverflow.com/questions/2050396/getting-the-date-of-a-net-assembly
                    //we use a simple method because the more Jeff Atwood's solution doesn't work anymore
                    //more info at https://blog.codinghorror.com/determining-build-date-the-hard-way/
                    loadedAssemblyModel.BuildDate = assembly.IsDynamic ? null : (DateTime?)TimeZoneInfo.ConvertTimeFromUtc(_fileProvider.GetLastWriteTimeUtc(assembly.Location), TimeZoneInfo.Local);
                }
                catch { }
                model.LoadedAssemblies.Add(loadedAssemblyModel);
            }

            return(model);
        }
Beispiel #21
0
        public void testDomain()
        {
            Console.WriteLine("clr.arch            :" + ((IntPtr.Size == 8) ? "64bit" : "32bit"));
            Console.WriteLine("clr.version         :" + RuntimeEnvironment.GetSystemVersion());
            Console.Out.Flush();

            string[] strings = DllRootHelper.findItems(@"file:/" + typeof(MyFirstRobot).Assembly.Location);
            Assert.GreaterOrEqual(strings.Length, 5);
        }
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            ExceptionBox.Text = string.Format(
                Properties.Resources.ExceptionReporterString,
                Assembly.GetExecutingAssembly().GetName().Version, DateTime.Now, Environment.OSVersion,
                AppDomain.CurrentDomain.BaseDirectory, Environment.CurrentDirectory, Environment.SystemDirectory,
                RuntimeEnvironment.GetSystemVersion(), App.IsAdministrator() ? "Admin" : "Non-Admin", _ex);

            Log.Info(ExceptionBox.Text);
        }
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     ExceptionBox.Text = $"Date: {DateTime.Now}\r\n" +
                         $"OS: {Environment.OSVersion}\r\n" +
                         $"Application Directory: {AppDomain.CurrentDomain.BaseDirectory}\r\n" +
                         $"Current Directory: {Environment.CurrentDirectory}\r\n" +
                         $"System Folder: {Environment.SystemDirectory}\r\n" +
                         $".NET Runtime: {RuntimeEnvironment.GetSystemVersion()}\r\n" +
                         $"Exception Details: {_ex}";
 }
Beispiel #24
0
        public AboutForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            versionLabel.Text    = "Version " + typeof(AboutForm).Assembly.GetName().Version;
            clrVersionLabel.Text = "Currently running on .NET Framework " + RuntimeEnvironment.GetSystemVersion() + ".";
        }
Beispiel #25
0
            public StrongNameVerifierLite()
            {
                _RuntimeVersion = RuntimeEnvironment.GetSystemVersion();
                if (int.Parse(_RuntimeVersion[1].ToString()) >= 4)
                {
                    _UsingComInterfaces = true;

                    InitializeComInterfaces();
                }
            }
Beispiel #26
0
        public void SanityCheck()
        {
            var zstdAsm = typeof(ZStdException).Assembly;

            var tf = zstdAsm.GetCustomAttribute <TargetFrameworkAttribute>();

            string commit = null;

            using (var proc = Process.Start(new ProcessStartInfo("git", "rev-parse HEAD")
            {
                RedirectStandardOutput = true
            })) {
                proc?.Start();
                commit = proc?.StandardOutput.ReadToEnd()?.Trim();
            }

            commit.Should().NotBeNullOrEmpty();

            Console.WriteLine($"Current commit according to git: {commit}");

            var version = zstdAsm.GetCustomAttribute <AssemblyInformationalVersionAttribute>()?.InformationalVersion;

            version.Should().NotBeNullOrEmpty();

            (version?.Split('+', 2)[1]).Should().Be(commit);

            Console.WriteLine($"Assembly Informational Version: {version}");

            Console.WriteLine($"Assembly Framework: {tf?.FrameworkName}");

            Console.WriteLine($"Runtime Framework Description: {RuntimeInformation.FrameworkDescription}");

            Console.WriteLine($"Runtime OS Version: {Environment.OSVersion}");

            Console.WriteLine($"Runtime Framework OS Description: {RuntimeInformation.OSDescription}");

            Console.WriteLine($"Runtime Framework OS Architecture: {RuntimeInformation.OSArchitecture}");

            Console.WriteLine($"Common Language Runtime Version: {Environment.Version}");

            Console.WriteLine($"Runtime Framework Process Architecture: {RuntimeInformation.ProcessArchitecture}");

            Console.WriteLine($"Runtime Framework Version: {RuntimeEnvironment.GetSystemVersion()}");

            Console.WriteLine($"Runtime Framework Directory: {RuntimeEnvironment.GetRuntimeDirectory()}");

            Console.WriteLine($"Processor Count: {Environment.ProcessorCount}");

            Console.WriteLine("Assembly Metadata:");
            foreach (var meta in zstdAsm.GetCustomAttributes <AssemblyMetadataAttribute>())
            {
                Console.WriteLine($"  {meta.Key}: {meta.Value}");
            }
        }
Beispiel #27
0
        public ActionResult SystemInfo()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            var model = new SystemInfoModel();

            try
            {
                model.OperatingSystem = Environment.OSVersion.VersionString;
            }
            catch (Exception)
            {
            }
            try
            {
                model.AspNetInfo = RuntimeEnvironment.GetSystemVersion();
            }
            catch (Exception)
            {
            }
            try
            {
                model.IsFullTrust = AppDomain.CurrentDomain.IsFullyTrusted.ToString();
            }
            catch (Exception)
            {
            }
            model.ServerTimeZone  = TimeZone.CurrentTimeZone.StandardName;
            model.ServerLocalTime = DateTime.Now;
            model.UtcTime         = DateTime.UtcNow;
            model.HttpHost        = _webHelper.ServerVariables("HTTP_HOST");
            foreach (var key in _httpContext.Request.ServerVariables.AllKeys)
            {
                model.ServerVariables.Add(new SystemInfoModel.ServerVariableModel
                {
                    Name  = key,
                    Value = _httpContext.Request.ServerVariables[key]
                });
            }
            //Environment.GetEnvironmentVariable("USERNAME");
            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                model.LoadedAssemblies.Add(new SystemInfoModel.LoadedAssembly
                {
                    FullName = assembly.FullName
                               //we cannot use Location property in medium trust
                               //Location = assembly.Location
                });
            }
            return(View(model));
        }
Beispiel #28
0
        /// <summary>
        /// Devuelve una instancia de frmAbout.
        /// </summary>
        public frmAbout(string name, string version, string copyright)
        {
            InitializeComponent();

            this.Text = "Acerca de " + name;
            this.lblProductName.Text = name;
            this.lblVersion.Text     = "Versión " + version;
            this.lblCopyright.Text   = copyright;
            this.lblFramework.Text   = "Framework .NET " + RuntimeEnvironment.GetSystemVersion();

            this.Icon = OTCForms.Icon;
        }
Beispiel #29
0
        static void Main(string[] args)
        {
            // Check out the runtime...
            Console.WriteLine("Runtime Directory is:\n-->{0}\n",
                              RuntimeEnvironment.GetRuntimeDirectory());

            Console.WriteLine("System Version is:\n-->{0}\n",
                              RuntimeEnvironment.GetSystemVersion());

            Console.WriteLine("Location of system config file is:\n-->{0}\n",
                              RuntimeEnvironment.SystemConfigurationFile);
        }
Beispiel #30
0
        /// <summary>
        /// Given the full path to a binary, determines a default CLR runtime version which
        /// should be used to debug it.
        /// </summary>
        /// <param name="filePath">The full path to a binary.</param>
        /// <returns>The CLR version string to use for debugging; null if unknown.</returns>
        public static string GetDefaultLaunchVersion(string filePath)
        {
            string version = GetDefaultRuntimeForFile(filePath);

            if (version != null)
            {
                return(version);
            }

            // If the binary doesn't bind to a clr then just debug it with the same
            // runtime this debugger is running in (a very arbitrary choice)
            return(RuntimeEnvironment.GetSystemVersion());
        }