mscorlib(4.0.0.0) API with additions
Environment.cs
1 using Microsoft.Win32;
2 using System.Collections;
3 using System.Diagnostics;
6 using System.IO;
7 using System.Resources;
11 using System.Security;
13 using System.Text;
14 using System.Threading;
15 
16 namespace System
17 {
19  [ComVisible(true)]
20  [__DynamicallyInvokable]
21  public static class Environment
22  {
23  internal sealed class ResourceHelper
24  {
25  internal class GetResourceStringUserData
26  {
27  public ResourceHelper m_resourceHelper;
28 
29  public string m_key;
30 
31  public CultureInfo m_culture;
32 
33  public string m_retVal;
34 
35  public bool m_lockWasTaken;
36 
37  public GetResourceStringUserData(ResourceHelper resourceHelper, string key, CultureInfo culture)
38  {
39  m_resourceHelper = resourceHelper;
40  m_key = key;
41  m_culture = culture;
42  }
43  }
44 
45  private string m_name;
46 
47  private ResourceManager SystemResMgr;
48 
49  private Stack currentlyLoading;
50 
51  internal bool resourceManagerInited;
52 
53  private int infinitelyRecursingCount;
54 
55  internal ResourceHelper(string name)
56  {
57  m_name = name;
58  }
59 
60  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
61  internal string GetResourceString(string key)
62  {
63  if (key == null || key.Length == 0)
64  {
65  return "[Resource lookup failed - null or empty resource name]";
66  }
67  return GetResourceString(key, null);
68  }
69 
70  [SecuritySafeCritical]
71  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
72  internal string GetResourceString(string key, CultureInfo culture)
73  {
74  if (key == null || key.Length == 0)
75  {
76  return "[Resource lookup failed - null or empty resource name]";
77  }
78  GetResourceStringUserData getResourceStringUserData = new GetResourceStringUserData(this, key, culture);
79  RuntimeHelpers.TryCode code = GetResourceStringCode;
80  RuntimeHelpers.CleanupCode backoutCode = GetResourceStringBackoutCode;
81  RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(code, backoutCode, getResourceStringUserData);
82  return getResourceStringUserData.m_retVal;
83  }
84 
85  [SecuritySafeCritical]
86  private void GetResourceStringCode(object userDataIn)
87  {
88  GetResourceStringUserData getResourceStringUserData = (GetResourceStringUserData)userDataIn;
89  ResourceHelper resourceHelper = getResourceStringUserData.m_resourceHelper;
90  string key = getResourceStringUserData.m_key;
91  CultureInfo culture = getResourceStringUserData.m_culture;
92  Monitor.Enter(resourceHelper, ref getResourceStringUserData.m_lockWasTaken);
93  if (resourceHelper.currentlyLoading != null && resourceHelper.currentlyLoading.Count > 0 && resourceHelper.currentlyLoading.Contains(key))
94  {
95  if (resourceHelper.infinitelyRecursingCount > 0)
96  {
97  getResourceStringUserData.m_retVal = "[Resource lookup failed - infinite recursion or critical failure detected.]";
98  return;
99  }
100  resourceHelper.infinitelyRecursingCount++;
101  string message = "Infinite recursion during resource lookup within mscorlib. This may be a bug in mscorlib, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names. Resource name: " + key;
102  Assert.Fail("[mscorlib recursive resource lookup bug]", message, -2146232797, System.Diagnostics.StackTrace.TraceFormat.NoResourceLookup);
103  FailFast(message);
104  }
105  if (resourceHelper.currentlyLoading == null)
106  {
107  resourceHelper.currentlyLoading = new Stack(4);
108  }
109  if (!resourceHelper.resourceManagerInited)
110  {
112  try
113  {
114  }
115  finally
116  {
119  RuntimeHelpers.RunClassConstructor(typeof(RuntimeResourceSet).TypeHandle);
120  RuntimeHelpers.RunClassConstructor(typeof(BinaryReader).TypeHandle);
121  resourceHelper.resourceManagerInited = true;
122  }
123  }
124  resourceHelper.currentlyLoading.Push(key);
125  if (resourceHelper.SystemResMgr == null)
126  {
127  resourceHelper.SystemResMgr = new ResourceManager(m_name, typeof(object).Assembly);
128  }
129  string @string = resourceHelper.SystemResMgr.GetString(key, null);
130  resourceHelper.currentlyLoading.Pop();
131  getResourceStringUserData.m_retVal = @string;
132  }
133 
134  [PrePrepareMethod]
135  private void GetResourceStringBackoutCode(object userDataIn, bool exceptionThrown)
136  {
137  GetResourceStringUserData getResourceStringUserData = (GetResourceStringUserData)userDataIn;
138  ResourceHelper resourceHelper = getResourceStringUserData.m_resourceHelper;
139  if (exceptionThrown && getResourceStringUserData.m_lockWasTaken)
140  {
141  resourceHelper.SystemResMgr = null;
142  resourceHelper.currentlyLoading = null;
143  }
144  if (getResourceStringUserData.m_lockWasTaken)
145  {
146  Monitor.Exit(resourceHelper);
147  }
148  }
149  }
150 
153  {
155  None = 0,
157  Create = 0x8000,
159  DoNotVerify = 0x4000
160  }
161 
163  [ComVisible(true)]
164  public enum SpecialFolder
165  {
167  ApplicationData = 26,
169  CommonApplicationData = 35,
171  LocalApplicationData = 28,
173  Cookies = 33,
175  Desktop = 0,
177  Favorites = 6,
179  History = 34,
181  InternetCache = 0x20,
183  Programs = 2,
185  MyComputer = 17,
187  MyMusic = 13,
189  MyPictures = 39,
191  MyVideos = 14,
193  Recent = 8,
195  SendTo = 9,
197  StartMenu = 11,
199  Startup = 7,
201  System = 37,
203  Templates = 21,
205  DesktopDirectory = 0x10,
207  Personal = 5,
209  MyDocuments = 5,
211  ProgramFiles = 38,
213  CommonProgramFiles = 43,
215  AdminTools = 48,
217  CDBurning = 59,
219  CommonAdminTools = 47,
221  CommonDocuments = 46,
223  CommonMusic = 53,
225  CommonOemLinks = 58,
227  CommonPictures = 54,
229  CommonStartMenu = 22,
231  CommonPrograms = 23,
233  CommonStartup = 24,
235  CommonDesktopDirectory = 25,
237  CommonTemplates = 45,
239  CommonVideos = 55,
241  Fonts = 20,
243  NetworkShortcuts = 19,
245  PrinterShortcuts = 27,
247  UserProfile = 40,
249  CommonProgramFilesX86 = 44,
251  ProgramFilesX86 = 42,
253  Resources = 56,
255  LocalizedResources = 57,
257  SystemX86 = 41,
259  Windows = 36
260  }
261 
262  private const int MaxEnvVariableValueLength = 32767;
263 
264  private const int MaxSystemEnvVariableLength = 1024;
265 
266  private const int MaxUserEnvVariableLength = 255;
267 
268  private static volatile ResourceHelper m_resHelper;
269 
270  private const int MaxMachineNameLength = 256;
271 
272  private static object s_InternalSyncObject;
273 
274  private static volatile OperatingSystem m_os;
275 
276  private static volatile bool s_IsWindows8OrAbove;
277 
278  private static volatile bool s_CheckedOSWin8OrAbove;
279 
280  private static volatile bool s_WinRTSupported;
281 
282  private static volatile bool s_CheckedWinRT;
283 
284  private static volatile IntPtr processWinStation;
285 
286  private static volatile bool isUserNonInteractive;
287 
288  private static object InternalSyncObject
289  {
290  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
291  get
292  {
293  if (s_InternalSyncObject == null)
294  {
295  object value = new object();
296  Interlocked.CompareExchange<object>(ref s_InternalSyncObject, value, (object)null);
297  }
298  return s_InternalSyncObject;
299  }
300  }
301 
304  [__DynamicallyInvokable]
305  public static int TickCount
306  {
307  [MethodImpl(MethodImplOptions.InternalCall)]
308  [SecuritySafeCritical]
309  [__DynamicallyInvokable]
310  get;
311  }
312 
315  public static int ExitCode
316  {
317  [MethodImpl(MethodImplOptions.InternalCall)]
318  [SecuritySafeCritical]
319  get;
320  [MethodImpl(MethodImplOptions.InternalCall)]
321  [SecuritySafeCritical]
322  set;
323  }
324 
325  internal static bool IsCLRHosted
326  {
327  [SecuritySafeCritical]
328  get
329  {
330  return GetIsCLRHosted();
331  }
332  }
333 
336  public static string CommandLine
337  {
338  [SecuritySafeCritical]
339  get
340  {
342  string s = null;
343  GetCommandLine(JitHelpers.GetStringHandleOnStack(ref s));
344  return s;
345  }
346  }
347 
355  public static string CurrentDirectory
356  {
357  get
358  {
360  }
361  set
362  {
364  }
365  }
366 
369  public static string SystemDirectory
370  {
371  [SecuritySafeCritical]
372  get
373  {
374  StringBuilder stringBuilder = new StringBuilder(260);
375  if (Win32Native.GetSystemDirectory(stringBuilder, 260) == 0)
376  {
377  __Error.WinIOError();
378  }
379  string text = stringBuilder.ToString();
380  FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, text);
381  return text;
382  }
383  }
384 
385  internal static string InternalWindowsDirectory
386  {
387  [SecurityCritical]
388  get
389  {
390  StringBuilder stringBuilder = new StringBuilder(260);
391  if (Win32Native.GetWindowsDirectory(stringBuilder, 260) == 0)
392  {
393  __Error.WinIOError();
394  }
395  return stringBuilder.ToString();
396  }
397  }
398 
402  public static string MachineName
403  {
404  [SecuritySafeCritical]
405  get
406  {
407  new EnvironmentPermission(EnvironmentPermissionAccess.Read, "COMPUTERNAME").Demand();
408  StringBuilder stringBuilder = new StringBuilder(256);
409  int bufferSize = 256;
410  if (Win32Native.GetComputerName(stringBuilder, ref bufferSize) == 0)
411  {
412  throw new InvalidOperationException(GetResourceString("InvalidOperation_ComputerName"));
413  }
414  return stringBuilder.ToString();
415  }
416  }
417 
420  [__DynamicallyInvokable]
421  public static int ProcessorCount
422  {
423  [SecuritySafeCritical]
424  [__DynamicallyInvokable]
425  get
426  {
427  return GetProcessorCount();
428  }
429  }
430 
433  public static int SystemPageSize
434  {
435  [SecuritySafeCritical]
436  get
437  {
438  new EnvironmentPermission(PermissionState.Unrestricted).Demand();
439  Win32Native.SYSTEM_INFO lpSystemInfo = default(Win32Native.SYSTEM_INFO);
440  Win32Native.GetSystemInfo(ref lpSystemInfo);
441  return lpSystemInfo.dwPageSize;
442  }
443  }
444 
447  [__DynamicallyInvokable]
448  public static string NewLine
449  {
450  [__DynamicallyInvokable]
451  get
452  {
453  return "\r\n";
454  }
455  }
456 
459  public static Version Version => new Version(4, 0, 30319, 42000);
460 
463  public static long WorkingSet
464  {
465  [SecuritySafeCritical]
466  get
467  {
468  new EnvironmentPermission(PermissionState.Unrestricted).Demand();
469  return GetWorkingSet();
470  }
471  }
472 
476  public static OperatingSystem OSVersion
477  {
478  [SecuritySafeCritical]
479  get
480  {
481  if (m_os == null)
482  {
483  Win32Native.OSVERSIONINFO oSVERSIONINFO = new Win32Native.OSVERSIONINFO();
484  if (!GetVersion(oSVERSIONINFO))
485  {
486  throw new InvalidOperationException(GetResourceString("InvalidOperation_GetVersion"));
487  }
488  Win32Native.OSVERSIONINFOEX oSVERSIONINFOEX = new Win32Native.OSVERSIONINFOEX();
489  if (!GetVersionEx(oSVERSIONINFOEX))
490  {
491  throw new InvalidOperationException(GetResourceString("InvalidOperation_GetVersion"));
492  }
493  PlatformID platform = PlatformID.Win32NT;
494  Version version = new Version(oSVERSIONINFO.MajorVersion, oSVERSIONINFO.MinorVersion, oSVERSIONINFO.BuildNumber, (oSVERSIONINFOEX.ServicePackMajor << 16) | oSVERSIONINFOEX.ServicePackMinor);
495  m_os = new OperatingSystem(platform, version, oSVERSIONINFO.CSDVersion);
496  }
497  return m_os;
498  }
499  }
500 
501  internal static bool IsWindows8OrAbove
502  {
503  get
504  {
505  if (!s_CheckedOSWin8OrAbove)
506  {
507  OperatingSystem oSVersion = OSVersion;
508  s_IsWindows8OrAbove = (oSVersion.Platform == PlatformID.Win32NT && ((oSVersion.Version.Major == 6 && oSVersion.Version.Minor >= 2) || oSVersion.Version.Major > 6));
509  s_CheckedOSWin8OrAbove = true;
510  }
511  return s_IsWindows8OrAbove;
512  }
513  }
514 
515  internal static bool IsWinRTSupported
516  {
517  [SecuritySafeCritical]
518  get
519  {
520  if (!s_CheckedWinRT)
521  {
522  s_WinRTSupported = WinRTSupported();
523  s_CheckedWinRT = true;
524  }
525  return s_WinRTSupported;
526  }
527  }
528 
531  [__DynamicallyInvokable]
532  public static string StackTrace
533  {
534  [SecuritySafeCritical]
535  [__DynamicallyInvokable]
536  get
537  {
538  new EnvironmentPermission(PermissionState.Unrestricted).Demand();
539  return GetStackTrace(null, needFileInfo: true);
540  }
541  }
542 
546  public static bool Is64BitProcess => true;
547 
551  public static bool Is64BitOperatingSystem
552  {
553  [SecuritySafeCritical]
554  get
555  {
556  return true;
557  }
558  }
559 
563  [__DynamicallyInvokable]
564  public static bool HasShutdownStarted
565  {
566  [MethodImpl(MethodImplOptions.InternalCall)]
567  [SecuritySafeCritical]
568  [__DynamicallyInvokable]
569  get;
570  }
571 
574  public static string UserName
575  {
576  [SecuritySafeCritical]
577  get
578  {
580  StringBuilder stringBuilder = new StringBuilder(256);
581  int nSize = stringBuilder.Capacity;
582  if (Win32Native.GetUserName(stringBuilder, ref nSize))
583  {
584  return stringBuilder.ToString();
585  }
586  return string.Empty;
587  }
588  }
589 
593  public static bool UserInteractive
594  {
595  [SecuritySafeCritical]
596  get
597  {
598  IntPtr processWindowStation = Win32Native.GetProcessWindowStation();
599  if (processWindowStation != IntPtr.Zero && processWinStation != processWindowStation)
600  {
601  int lpnLengthNeeded = 0;
602  Win32Native.USEROBJECTFLAGS uSEROBJECTFLAGS = new Win32Native.USEROBJECTFLAGS();
603  if (Win32Native.GetUserObjectInformation(processWindowStation, 1, uSEROBJECTFLAGS, Marshal.SizeOf(uSEROBJECTFLAGS), ref lpnLengthNeeded) && (uSEROBJECTFLAGS.dwFlags & 1) == 0)
604  {
605  isUserNonInteractive = true;
606  }
607  processWinStation = processWindowStation;
608  }
609  return !isUserNonInteractive;
610  }
611  }
612 
617  public static string UserDomainName
618  {
619  [SecuritySafeCritical]
620  get
621  {
622  new EnvironmentPermission(EnvironmentPermissionAccess.Read, "UserDomain").Demand();
623  byte[] array = new byte[1024];
624  int sidLen = array.Length;
625  StringBuilder stringBuilder = new StringBuilder(1024);
626  uint domainNameLen = (uint)stringBuilder.Capacity;
627  byte userNameEx = Win32Native.GetUserNameEx(2, stringBuilder, ref domainNameLen);
628  if (userNameEx == 1)
629  {
630  string text = stringBuilder.ToString();
631  int num = text.IndexOf('\\');
632  if (num != -1)
633  {
634  return text.Substring(0, num);
635  }
636  }
637  domainNameLen = (uint)stringBuilder.Capacity;
638  if (!Win32Native.LookupAccountName(null, UserName, array, ref sidLen, stringBuilder, ref domainNameLen, out int _))
639  {
640  int lastWin32Error = Marshal.GetLastWin32Error();
641  throw new InvalidOperationException(Win32Native.GetMessage(lastWin32Error));
642  }
643  return stringBuilder.ToString();
644  }
645  }
646 
649  [__DynamicallyInvokable]
650  public static int CurrentManagedThreadId
651  {
652  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
653  [__DynamicallyInvokable]
654  get
655  {
657  }
658  }
659 
660  [DllImport("QCall", CharSet = CharSet.Unicode)]
661  [SecurityCritical]
662  [SuppressUnmanagedCodeSecurity]
663  internal static extern void _Exit(int exitCode);
664 
668  [SecuritySafeCritical]
669  [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
670  public static void Exit(int exitCode)
671  {
672  _Exit(exitCode);
673  }
674 
677  [MethodImpl(MethodImplOptions.InternalCall)]
678  [SecurityCritical]
679  [__DynamicallyInvokable]
680  public static extern void FailFast(string message);
681 
682  [MethodImpl(MethodImplOptions.InternalCall)]
683  [SecurityCritical]
684  internal static extern void FailFast(string message, uint exitCode);
685 
689  [MethodImpl(MethodImplOptions.InternalCall)]
690  [SecurityCritical]
691  [__DynamicallyInvokable]
692  public static extern void FailFast(string message, Exception exception);
693 
694  [DllImport("QCall", CharSet = CharSet.Unicode)]
695  [SecurityCritical]
696  [SuppressUnmanagedCodeSecurity]
697  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
698  internal static extern void TriggerCodeContractFailure(ContractFailureKind failureKind, string message, string condition, string exceptionAsString);
699 
700  [DllImport("QCall", CharSet = CharSet.Unicode)]
701  [SecurityCritical]
702  [SuppressUnmanagedCodeSecurity]
703  [return: MarshalAs(UnmanagedType.Bool)]
704  private static extern bool GetIsCLRHosted();
705 
706  [DllImport("QCall", CharSet = CharSet.Unicode)]
707  [SecurityCritical]
708  [SuppressUnmanagedCodeSecurity]
709  private static extern void GetCommandLine(StringHandleOnStack retString);
710 
716  [SecuritySafeCritical]
717  [__DynamicallyInvokable]
718  public static string ExpandEnvironmentVariables(string name)
719  {
720  if (name == null)
721  {
722  throw new ArgumentNullException("name");
723  }
724  if (name.Length == 0)
725  {
726  return name;
727  }
728  if (AppDomain.IsAppXModel() && !AppDomain.IsAppXDesignMode())
729  {
730  return name;
731  }
732  int num = 100;
733  StringBuilder stringBuilder = new StringBuilder(num);
734  bool flag = CodeAccessSecurityEngine.QuickCheckForAllDemands();
735  string[] array = name.Split('%');
736  StringBuilder stringBuilder2 = flag ? null : new StringBuilder();
737  bool flag2 = false;
738  int num2;
739  for (int i = 1; i < array.Length - 1; i++)
740  {
741  if ((array[i].Length == 0) | flag2)
742  {
743  flag2 = false;
744  continue;
745  }
746  stringBuilder.Length = 0;
747  string text = "%" + array[i] + "%";
748  num2 = Win32Native.ExpandEnvironmentStrings(text, stringBuilder, num);
749  if (num2 == 0)
750  {
752  }
753  while (num2 > num)
754  {
755  num = (stringBuilder.Capacity = num2);
756  stringBuilder.Length = 0;
757  num2 = Win32Native.ExpandEnvironmentStrings(text, stringBuilder, num);
758  if (num2 == 0)
759  {
761  }
762  }
763  if (!flag)
764  {
765  string a = stringBuilder.ToString();
766  flag2 = (a != text);
767  if (flag2)
768  {
769  stringBuilder2.Append(array[i]);
770  stringBuilder2.Append(';');
771  }
772  }
773  }
774  if (!flag)
775  {
776  new EnvironmentPermission(EnvironmentPermissionAccess.Read, stringBuilder2.ToString()).Demand();
777  }
778  stringBuilder.Length = 0;
779  num2 = Win32Native.ExpandEnvironmentStrings(name, stringBuilder, num);
780  if (num2 == 0)
781  {
783  }
784  while (num2 > num)
785  {
786  num = (stringBuilder.Capacity = num2);
787  stringBuilder.Length = 0;
788  num2 = Win32Native.ExpandEnvironmentStrings(name, stringBuilder, num);
789  if (num2 == 0)
790  {
792  }
793  }
794  return stringBuilder.ToString();
795  }
796 
797  [DllImport("QCall", CharSet = CharSet.Unicode)]
798  [SecurityCritical]
799  [SuppressUnmanagedCodeSecurity]
800  private static extern int GetProcessorCount();
801 
805  [SecuritySafeCritical]
806  public static string[] GetCommandLineArgs()
807  {
809  return GetCommandLineArgsNative();
810  }
811 
812  [MethodImpl(MethodImplOptions.InternalCall)]
813  [SecurityCritical]
814  private static extern string[] GetCommandLineArgsNative();
815 
816  [MethodImpl(MethodImplOptions.InternalCall)]
817  [SecurityCritical]
818  internal static extern string nativeGetEnvironmentVariable(string variable);
819 
826  [SecuritySafeCritical]
827  [__DynamicallyInvokable]
828  public static string GetEnvironmentVariable(string variable)
829  {
830  if (variable == null)
831  {
832  throw new ArgumentNullException("variable");
833  }
834  if (AppDomain.IsAppXModel() && !AppDomain.IsAppXDesignMode())
835  {
836  return null;
837  }
839  StringBuilder stringBuilder = StringBuilderCache.Acquire(128);
840  int environmentVariable = Win32Native.GetEnvironmentVariable(variable, stringBuilder, stringBuilder.Capacity);
841  if (environmentVariable == 0 && Marshal.GetLastWin32Error() == 203)
842  {
843  StringBuilderCache.Release(stringBuilder);
844  return null;
845  }
846  while (environmentVariable > stringBuilder.Capacity)
847  {
848  stringBuilder.Capacity = environmentVariable;
849  stringBuilder.Length = 0;
850  environmentVariable = Win32Native.GetEnvironmentVariable(variable, stringBuilder, stringBuilder.Capacity);
851  }
852  return StringBuilderCache.GetStringAndRelease(stringBuilder);
853  }
854 
864  [SecuritySafeCritical]
865  public static string GetEnvironmentVariable(string variable, EnvironmentVariableTarget target)
866  {
867  if (variable == null)
868  {
869  throw new ArgumentNullException("variable");
870  }
871  if (target == EnvironmentVariableTarget.Process)
872  {
873  return GetEnvironmentVariable(variable);
874  }
875  new EnvironmentPermission(PermissionState.Unrestricted).Demand();
876  switch (target)
877  {
878  case EnvironmentVariableTarget.Machine:
879  using (RegistryKey registryKey2 = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Session Manager\\Environment", writable: false))
880  {
881  if (registryKey2 == null)
882  {
883  return null;
884  }
885  return registryKey2.GetValue(variable) as string;
886  }
887  case EnvironmentVariableTarget.User:
888  using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Environment", writable: false))
889  {
890  if (registryKey == null)
891  {
892  return null;
893  }
894  return registryKey.GetValue(variable) as string;
895  }
896  default:
897  throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)target));
898  }
899  }
900 
901  [SecurityCritical]
902  private unsafe static char[] GetEnvironmentCharArray()
903  {
904  char[] result = null;
906  try
907  {
908  return result;
909  }
910  finally
911  {
912  char* ptr = null;
913  try
914  {
915  ptr = Win32Native.GetEnvironmentStrings();
916  if (ptr == null)
917  {
918  throw new OutOfMemoryException();
919  }
920  char* ptr2;
921  for (ptr2 = ptr; *ptr2 != 0 || ptr2[1] != 0; ptr2++)
922  {
923  }
924  int num = (int)(ptr2 - ptr + 1);
925  result = new char[num];
926  try
927  {
928  char[] array = result;
929  fixed (char* dmem = array)
930  {
931  string.wstrcpy(dmem, ptr, num);
932  }
933  }
934  finally
935  {
936  }
937  }
938  finally
939  {
940  if (ptr != null)
941  {
942  Win32Native.FreeEnvironmentStrings(ptr);
943  }
944  }
945  }
946  }
947 
952  [SecuritySafeCritical]
953  [__DynamicallyInvokable]
955  {
956  if (AppDomain.IsAppXModel() && !AppDomain.IsAppXDesignMode())
957  {
958  return new Hashtable(0);
959  }
960  bool flag = CodeAccessSecurityEngine.QuickCheckForAllDemands();
961  StringBuilder stringBuilder = flag ? null : new StringBuilder();
962  bool flag2 = true;
963  char[] environmentCharArray = GetEnvironmentCharArray();
964  Hashtable hashtable = new Hashtable(20);
965  for (int i = 0; i < environmentCharArray.Length; i++)
966  {
967  int num = i;
968  for (; environmentCharArray[i] != '=' && environmentCharArray[i] != 0; i++)
969  {
970  }
971  if (environmentCharArray[i] == '\0')
972  {
973  continue;
974  }
975  if (i - num == 0)
976  {
977  for (; environmentCharArray[i] != 0; i++)
978  {
979  }
980  continue;
981  }
982  string text = new string(environmentCharArray, num, i - num);
983  i++;
984  int num2 = i;
985  for (; environmentCharArray[i] != 0; i++)
986  {
987  }
988  string text3 = (string)(hashtable[text] = new string(environmentCharArray, num2, i - num2));
989  if (!flag)
990  {
991  if (flag2)
992  {
993  flag2 = false;
994  }
995  else
996  {
997  stringBuilder.Append(';');
998  }
999  stringBuilder.Append(text);
1000  }
1001  }
1002  if (!flag)
1003  {
1004  new EnvironmentPermission(EnvironmentPermissionAccess.Read, stringBuilder.ToString()).Demand();
1005  }
1006  return hashtable;
1007  }
1008 
1009  internal static IDictionary GetRegistryKeyNameValuePairs(RegistryKey registryKey)
1010  {
1011  Hashtable hashtable = new Hashtable(20);
1012  if (registryKey != null)
1013  {
1014  string[] valueNames = registryKey.GetValueNames();
1015  string[] array = valueNames;
1016  foreach (string text in array)
1017  {
1018  string value = registryKey.GetValue(text, "").ToString();
1019  hashtable.Add(text, value);
1020  }
1021  }
1022  return hashtable;
1023  }
1024 
1031  [SecuritySafeCritical]
1033  {
1034  if (target == EnvironmentVariableTarget.Process)
1035  {
1036  return GetEnvironmentVariables();
1037  }
1038  new EnvironmentPermission(PermissionState.Unrestricted).Demand();
1039  switch (target)
1040  {
1041  case EnvironmentVariableTarget.Machine:
1042  using (RegistryKey registryKey2 = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Session Manager\\Environment", writable: false))
1043  {
1044  return GetRegistryKeyNameValuePairs(registryKey2);
1045  }
1046  case EnvironmentVariableTarget.User:
1047  using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Environment", writable: false))
1048  {
1049  return GetRegistryKeyNameValuePairs(registryKey);
1050  }
1051  default:
1052  throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)target));
1053  }
1054  }
1055 
1064  [SecuritySafeCritical]
1065  [__DynamicallyInvokable]
1066  public static void SetEnvironmentVariable(string variable, string value)
1067  {
1068  CheckEnvironmentVariableName(variable);
1069  new EnvironmentPermission(PermissionState.Unrestricted).Demand();
1070  if (string.IsNullOrEmpty(value) || value[0] == '\0')
1071  {
1072  value = null;
1073  }
1074  else if (value.Length >= 32767)
1075  {
1076  throw new ArgumentException(GetResourceString("Argument_LongEnvVarValue"));
1077  }
1078  if (AppDomain.IsAppXModel() && !AppDomain.IsAppXDesignMode())
1079  {
1080  throw new PlatformNotSupportedException();
1081  }
1082  if (!Win32Native.SetEnvironmentVariable(variable, value))
1083  {
1084  int lastWin32Error = Marshal.GetLastWin32Error();
1085  switch (lastWin32Error)
1086  {
1087  case 203:
1088  break;
1089  case 206:
1090  throw new ArgumentException(GetResourceString("Argument_LongEnvVarValue"));
1091  default:
1092  throw new ArgumentException(Win32Native.GetMessage(lastWin32Error));
1093  }
1094  }
1095  }
1096 
1097  private static void CheckEnvironmentVariableName(string variable)
1098  {
1099  if (variable == null)
1100  {
1101  throw new ArgumentNullException("variable");
1102  }
1103  if (variable.Length == 0)
1104  {
1105  throw new ArgumentException(GetResourceString("Argument_StringZeroLength"), "variable");
1106  }
1107  if (variable[0] == '\0')
1108  {
1109  throw new ArgumentException(GetResourceString("Argument_StringFirstCharIsZero"), "variable");
1110  }
1111  if (variable.Length >= 32767)
1112  {
1113  throw new ArgumentException(GetResourceString("Argument_LongEnvVarValue"));
1114  }
1115  if (variable.IndexOf('=') != -1)
1116  {
1117  throw new ArgumentException(GetResourceString("Argument_IllegalEnvVarName"));
1118  }
1119  }
1120 
1133  [SecuritySafeCritical]
1134  public static void SetEnvironmentVariable(string variable, string value, EnvironmentVariableTarget target)
1135  {
1136  if (target == EnvironmentVariableTarget.Process)
1137  {
1138  SetEnvironmentVariable(variable, value);
1139  return;
1140  }
1141  CheckEnvironmentVariableName(variable);
1142  if (variable.Length >= 1024)
1143  {
1144  throw new ArgumentException(GetResourceString("Argument_LongEnvVarName"));
1145  }
1146  new EnvironmentPermission(PermissionState.Unrestricted).Demand();
1147  if (string.IsNullOrEmpty(value) || value[0] == '\0')
1148  {
1149  value = null;
1150  }
1151  switch (target)
1152  {
1153  case EnvironmentVariableTarget.Machine:
1154  using (RegistryKey registryKey2 = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Session Manager\\Environment", writable: true))
1155  {
1156  if (registryKey2 != null)
1157  {
1158  if (value == null)
1159  {
1160  registryKey2.DeleteValue(variable, throwOnMissingValue: false);
1161  }
1162  else
1163  {
1164  registryKey2.SetValue(variable, value);
1165  }
1166  }
1167  }
1168  break;
1169  case EnvironmentVariableTarget.User:
1170  if (variable.Length >= 255)
1171  {
1172  throw new ArgumentException(GetResourceString("Argument_LongEnvVarValue"));
1173  }
1174  using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Environment", writable: true))
1175  {
1176  if (registryKey != null)
1177  {
1178  if (value == null)
1179  {
1180  registryKey.DeleteValue(variable, throwOnMissingValue: false);
1181  }
1182  else
1183  {
1184  registryKey.SetValue(variable, value);
1185  }
1186  }
1187  }
1188  break;
1189  default:
1190  throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)target));
1191  }
1192  IntPtr value2 = Win32Native.SendMessageTimeout(new IntPtr(65535), 26, IntPtr.Zero, "Environment", 0u, 1000u, IntPtr.Zero);
1193  bool flag = value2 == IntPtr.Zero;
1194  }
1195 
1200  [SecuritySafeCritical]
1201  public static string[] GetLogicalDrives()
1202  {
1203  new EnvironmentPermission(PermissionState.Unrestricted).Demand();
1204  int logicalDrives = Win32Native.GetLogicalDrives();
1205  if (logicalDrives == 0)
1206  {
1207  __Error.WinIOError();
1208  }
1209  uint num = (uint)logicalDrives;
1210  int num2 = 0;
1211  while (num != 0)
1212  {
1213  if ((num & 1) != 0)
1214  {
1215  num2++;
1216  }
1217  num >>= 1;
1218  }
1219  string[] array = new string[num2];
1220  char[] array2 = new char[3]
1221  {
1222  'A',
1223  ':',
1224  '\\'
1225  };
1226  num = (uint)logicalDrives;
1227  num2 = 0;
1228  while (num != 0)
1229  {
1230  if ((num & 1) != 0)
1231  {
1232  array[num2++] = new string(array2);
1233  }
1234  num >>= 1;
1235  array2[0] += '\u0001';
1236  }
1237  return array;
1238  }
1239 
1240  [DllImport("QCall", CharSet = CharSet.Unicode)]
1241  [SecurityCritical]
1242  [SuppressUnmanagedCodeSecurity]
1243  private static extern long GetWorkingSet();
1244 
1245  [DllImport("QCall", CharSet = CharSet.Unicode)]
1246  [SecurityCritical]
1247  [SuppressUnmanagedCodeSecurity]
1248  [return: MarshalAs(UnmanagedType.Bool)]
1249  private static extern bool WinRTSupported();
1250 
1251  [MethodImpl(MethodImplOptions.InternalCall)]
1252  [SecurityCritical]
1253  internal static extern bool GetVersion(Win32Native.OSVERSIONINFO osVer);
1254 
1255  [MethodImpl(MethodImplOptions.InternalCall)]
1256  [SecurityCritical]
1257  internal static extern bool GetVersionEx(Win32Native.OSVERSIONINFOEX osVer);
1258 
1259  internal static string GetStackTrace(Exception e, bool needFileInfo)
1260  {
1261  StackTrace stackTrace = (e != null) ? new StackTrace(e, needFileInfo) : new StackTrace(needFileInfo);
1262  return stackTrace.ToString(System.Diagnostics.StackTrace.TraceFormat.Normal);
1263  }
1264 
1265  [SecuritySafeCritical]
1266  private static void InitResourceHelper()
1267  {
1268  bool lockTaken = false;
1270  try
1271  {
1272  Monitor.Enter(InternalSyncObject, ref lockTaken);
1273  if (m_resHelper == null)
1274  {
1275  ResourceHelper resHelper = new ResourceHelper("mscorlib");
1277  m_resHelper = resHelper;
1278  }
1279  }
1280  finally
1281  {
1282  if (lockTaken)
1283  {
1284  Monitor.Exit(InternalSyncObject);
1285  }
1286  }
1287  }
1288 
1289  [MethodImpl(MethodImplOptions.InternalCall)]
1290  [SecurityCritical]
1291  internal static extern string GetResourceFromDefault(string key);
1292 
1293  internal static string GetResourceStringLocal(string key)
1294  {
1295  if (m_resHelper == null)
1296  {
1297  InitResourceHelper();
1298  }
1299  return m_resHelper.GetResourceString(key);
1300  }
1301 
1302  [SecuritySafeCritical]
1303  internal static string GetResourceString(string key)
1304  {
1305  return GetResourceFromDefault(key);
1306  }
1307 
1308  [SecuritySafeCritical]
1309  internal static string GetResourceString(string key, params object[] values)
1310  {
1311  string resourceString = GetResourceString(key);
1312  return string.Format(CultureInfo.CurrentCulture, resourceString, values);
1313  }
1314 
1315  internal static string GetRuntimeResourceString(string key)
1316  {
1317  return GetResourceString(key);
1318  }
1319 
1320  internal static string GetRuntimeResourceString(string key, params object[] values)
1321  {
1322  return GetResourceString(key, values);
1323  }
1324 
1325  [MethodImpl(MethodImplOptions.InternalCall)]
1326  [SecurityCritical]
1327  internal static extern bool GetCompatibilityFlag(CompatibilityFlag flag);
1328 
1335  [SecuritySafeCritical]
1336  public static string GetFolderPath(SpecialFolder folder)
1337  {
1338  if (!Enum.IsDefined(typeof(SpecialFolder), folder))
1339  {
1340  throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)folder));
1341  }
1342  return InternalGetFolderPath(folder, SpecialFolderOption.None);
1343  }
1344 
1354  [SecuritySafeCritical]
1355  public static string GetFolderPath(SpecialFolder folder, SpecialFolderOption option)
1356  {
1357  if (!Enum.IsDefined(typeof(SpecialFolder), folder))
1358  {
1359  throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)folder));
1360  }
1361  if (!Enum.IsDefined(typeof(SpecialFolderOption), option))
1362  {
1363  throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)option));
1364  }
1365  return InternalGetFolderPath(folder, option);
1366  }
1367 
1368  [SecurityCritical]
1369  internal static string UnsafeGetFolderPath(SpecialFolder folder)
1370  {
1371  return InternalGetFolderPath(folder, SpecialFolderOption.None, suppressSecurityChecks: true);
1372  }
1373 
1374  [SecurityCritical]
1375  private static string InternalGetFolderPath(SpecialFolder folder, SpecialFolderOption option, bool suppressSecurityChecks = false)
1376  {
1377  if (option == SpecialFolderOption.Create && !suppressSecurityChecks)
1378  {
1379  FileIOPermission fileIOPermission = new FileIOPermission(PermissionState.None);
1380  fileIOPermission.AllFiles = FileIOPermissionAccess.Write;
1381  fileIOPermission.Demand();
1382  }
1383  StringBuilder stringBuilder = new StringBuilder(260);
1384  int num = Win32Native.SHGetFolderPath(IntPtr.Zero, (int)folder | (int)option, IntPtr.Zero, 0, stringBuilder);
1385  string text;
1386  if (num < 0)
1387  {
1388  if (num == -2146233031)
1389  {
1390  throw new PlatformNotSupportedException();
1391  }
1392  text = string.Empty;
1393  }
1394  else
1395  {
1396  text = stringBuilder.ToString();
1397  }
1398  if (!suppressSecurityChecks)
1399  {
1400  new FileIOPermission(FileIOPermissionAccess.PathDiscovery, text).Demand();
1401  }
1402  return text;
1403  }
1404  }
1405 }
static Thread CurrentThread
Gets the currently running thread.
Definition: Thread.cs:134
delegate void TryCode(object userData)
Represents a delegate to code that should be run in a try block..
static string NewLine
Gets the newline string defined for this environment.
Definition: Environment.cs:449
static void Exit(int exitCode)
Terminates this process and returns an exit code to the operating system.
Definition: Environment.cs:670
PlatformID
Identifies the operating system, or platform, supported by an assembly.
Definition: PlatformID.cs:8
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
FileIOPermissionAccess
Specifies the type of file access requested.
virtual void Add(object key, object value)
Adds an element with the specified key and value into the T:System.Collections.Hashtable.
Definition: Hashtable.cs:916
Represents a simple last-in-first-out (LIFO) non-generic collection of objects.
Definition: Stack.cs:13
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
static void MemoryBarrier()
Synchronizes memory access as follows: The processor executing the current thread cannot reorder inst...
SpecialFolder
Specifies enumerated constants used to retrieve directory paths to system special folders.
Definition: Environment.cs:164
static void ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, object userData)
Executes code using a T:System.Delegate while using another T:System.Delegate to execute additional c...
static int ExitCode
Gets or sets the exit code of the process.
Definition: Environment.cs:316
Represents a stack trace, which is an ordered collection of one or more stack frames.
Definition: StackTrace.cs:16
static string ExpandEnvironmentVariables(string name)
Replaces the name of each environment variable embedded in the specified string with the string equiv...
Definition: Environment.cs:718
static int SystemPageSize
Gets the number of bytes in the operating system's memory page.
Definition: Environment.cs:434
Definition: __Canon.cs:3
Provides a mechanism that synchronizes access to objects.
Definition: Monitor.cs:13
static int SizeOf(object structure)
Returns the unmanaged size of an object in bytes.
Definition: Marshal.cs:159
static bool HasShutdownStarted
Gets a value that indicates whether the current application domain is being unloaded or the common la...
Definition: Environment.cs:565
static OperatingSystem OSVersion
Gets an T:System.OperatingSystem object that contains the current platform identifier and version num...
Definition: Environment.cs:477
static bool Is64BitOperatingSystem
Determines whether the current operating system is a 64-bit operating system.
Definition: Environment.cs:552
EnvironmentPermissionAccess
Specifies access to environment variables.
static int GetHRForLastWin32Error()
Returns the HRESULT corresponding to the last error incurred by Win32 code executed using T:System....
Definition: Marshal.cs:1072
static IDictionary GetEnvironmentVariables()
Retrieves all environment variable names and their values from the current process.
Definition: Environment.cs:954
static string CommandLine
Gets the command line for this process.
Definition: Environment.cs:337
static string GetEnvironmentVariable(string variable)
Retrieves the value of an environment variable from the current process.
Definition: Environment.cs:828
Specifies that the operating system should create a new file. If the file already exists,...
Represents a resource manager that provides convenient access to culture-specific resources at run ti...
Represents an application domain, which is an isolated environment where applications execute....
Definition: AppDomain.cs:33
Version Version
Gets a T:System.Version object that identifies the operating system.
EnvironmentVariableTarget
Specifies the location where an environment variable is stored or retrieved in a set or get operation...
static Version Version
Gets a T:System.Version object that describes the major, minor, build, and revision numbers of the co...
Definition: Environment.cs:459
Cer
Specifies a method's behavior when called within a constrained execution region.
Definition: Cer.cs:5
PlatformID Platform
Gets a T:System.PlatformID enumeration value that identifies the operating system platform.
static void SetEnvironmentVariable(string variable, string value, EnvironmentVariableTarget target)
Creates, modifies, or deletes an environment variable stored in the current process or in the Windows...
static string GetFolderPath(SpecialFolder folder)
Gets the path to the system special folder that is identified by the specified enumeration.
SecurityAction
Specifies the security actions that can be performed using declarative security.
static void Enter(object obj)
Acquires an exclusive lock on the specified object.
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
static bool IsDefined(Type enumType, object value)
Returns an indication whether a constant with a specified value exists in a specified enumeration.
Definition: Enum.cs:577
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
int Major
Gets the value of the major component of the version number for the current T:System....
Definition: Version.cs:103
static string MachineName
Gets the NetBIOS name of this local computer.
Definition: Environment.cs:403
UnmanagedType
Identifies how to marshal parameters or fields to unmanaged code.
Definition: UnmanagedType.cs:7
Provides the base class for enumerations.
Definition: Enum.cs:14
Exposes static methods for creating, moving, and enumerating through directories and subdirectories....
Definition: Directory.cs:14
static void SetCurrentDirectory(string path)
Sets the application's current working directory to the specified directory.
Definition: Directory.cs:1372
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
Represents a collection of key/value pairs that are organized based on the hash code of the key....
Definition: Hashtable.cs:17
static string SystemDirectory
Gets the fully qualified path of the system directory.
Definition: Environment.cs:370
Reads primitive data types as binary values in a specific encoding.
Definition: BinaryReader.cs:10
static void ThrowExceptionForHR(int errorCode)
Throws an exception with a specific failure HRESULT value.
Definition: Marshal.cs:1323
int Length
Gets or sets the length of the current T:System.Text.StringBuilder object.
static string StackTrace
Gets current stack trace information.
Definition: Environment.cs:533
static int ProcessorCount
Gets the number of processors on the current machine.
Definition: Environment.cs:422
The exception that is thrown when a feature does not run on a particular platform.
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
static void Exit(object obj)
Releases an exclusive lock on the specified object.
static void PrepareConstrainedRegions()
Designates a body of code as a constrained execution region (CER).
static string UserDomainName
Gets the network domain name associated with the current user.
Definition: Environment.cs:618
override string ToString()
Builds a readable representation of the stack trace.
Definition: StackTrace.cs:286
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
Definition: Marshal.cs:15
static int TickCount
Gets the number of milliseconds elapsed since the system started.
Definition: Environment.cs:306
static string GetEnvironmentVariable(string variable, EnvironmentVariableTarget target)
Retrieves the value of an environment variable from the current process or from the Windows operating...
Definition: Environment.cs:865
static string [] GetLogicalDrives()
Returns an array of string containing the names of the logical drives on the current computer.
Represents the version number of an assembly, operating system, or the common language runtime....
Definition: Version.cs:11
MethodImplOptions
Defines the details of how a method is implemented.
FileIOPermissionAccess AllFiles
Gets or sets the permitted access to all files.
CharSet
Dictates which character set marshaled strings should use.
Definition: CharSet.cs:7
static string GetCurrentDirectory()
Gets the current working directory of the application.
Definition: Directory.cs:1288
Enumerates the resources in a binary resources (.resources) file by reading sequential resource name/...
An Overload:System.Diagnostics.Contracts.Contract.Assert contract failed.
static bool UserInteractive
Gets a value indicating whether the current process is running in user interactive mode.
Definition: Environment.cs:594
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
static string GetFolderPath(SpecialFolder folder, SpecialFolderOption option)
Gets the path to the system special folder that is identified by the specified enumeration,...
static string UserName
Gets the user name of the person who is currently logged on to the Windows operating system.
Definition: Environment.cs:575
Represents information about an operating system, such as the version and platform identifier....
static int CurrentManagedThreadId
Gets a unique identifier for the current managed thread.
Definition: Environment.cs:651
static bool Is64BitProcess
Determines whether the current process is a 64-bit process.
Definition: Environment.cs:546
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
Definition: CultureInfo.cs:120
Attribute can be applied to an assembly.
The exception that is thrown when one of the arguments provided to a method is not valid.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
int Capacity
Gets or sets the maximum number of characters that can be contained in the memory allocated by the cu...
static long WorkingSet
Gets the amount of physical memory mapped to the process context.
Definition: Environment.cs:464
int ManagedThreadId
Gets a unique identifier for the current managed thread.
Definition: Thread.cs:55
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
Definition: Exception.cs:22
The local computer zone is an implicit zone used for content that exists on the user's computer.
int Minor
Gets the value of the minor component of the version number for the current T:System....
Definition: Version.cs:115
SpecialFolderOption
Specifies options to use for getting the path to a special folder.
Definition: Environment.cs:152
static IDictionary GetEnvironmentVariables(EnvironmentVariableTarget target)
Retrieves all environment variable names and their values from the current process,...
delegate void CleanupCode(object userData, bool exceptionThrown)
Represents a method to run when an exception occurs.
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
Definition: IntPtr.cs:20
static string [] GetCommandLineArgs()
Returns a string array containing the command-line arguments for the current process.
Definition: Environment.cs:806
The exception that is thrown when a method call is invalid for the object's current state.
Controls access to system and user environment variables. This class cannot be inherited.
Consistency
Specifies a reliability contract.
Definition: Consistency.cs:5
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
Controls the ability to access files and folders. This class cannot be inherited.
static int GetLastWin32Error()
Returns the error code returned by the last unmanaged function that was called using platform invoke ...
static void RunClassConstructor(RuntimeTypeHandle type)
Runs a specified class constructor method.
SecurityPermissionFlag
Specifies access flags for the security permission object.
static string CurrentDirectory
Gets or sets the fully qualified path of the current working directory.
Definition: Environment.cs:356
Represents a nongeneric collection of key/value pairs.
Definition: IDictionary.cs:8
Provides atomic operations for variables that are shared by multiple threads.
Definition: Interlocked.cs:10
static void SetEnvironmentVariable(string variable, string value)
Creates, modifies, or deletes an environment variable stored in the current process.
static void FailFast(string message)
Immediately terminates a process after writing a message to the Windows Application event log,...
Provides a set of static methods and properties that provide support for compilers....
ContractFailureKind
Specifies the type of contract that failed.
Creates and controls a thread, sets its priority, and gets its status.
Definition: Thread.cs:18