Delete System.AppDomainSetup (dotnet/coreclr#21157)
authorJan Kotas <jkotas@microsoft.com>
Thu, 22 Nov 2018 22:22:40 +0000 (14:22 -0800)
committerGitHub <noreply@github.com>
Thu, 22 Nov 2018 22:22:40 +0000 (14:22 -0800)
* Delete System.AppDomainSetup

Contributes to dotnet/coreclr#21028

* Add test hook for null entry assembly

* Validate that the binder paths are absolute

Commit migrated from https://github.com/dotnet/coreclr/commit/e54dffef08c22a94962aacd93d4793b377cac632

29 files changed:
src/coreclr/src/System.Private.CoreLib/Resources/Strings.resx
src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj
src/coreclr/src/System.Private.CoreLib/src/System/Activator.cs
src/coreclr/src/System.Private.CoreLib/src/System/AppContext/AppContext.cs
src/coreclr/src/System.Private.CoreLib/src/System/AppDomain.cs
src/coreclr/src/System.Private.CoreLib/src/System/AppDomainManager.cs [deleted file]
src/coreclr/src/System.Private.CoreLib/src/System/AppDomainSetup.cs [deleted file]
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs [deleted file]
src/coreclr/src/binder/applicationcontext.cpp
src/coreclr/src/classlibnative/bcltype/system.cpp
src/coreclr/src/classlibnative/bcltype/system.h
src/coreclr/src/vm/appdomain.cpp
src/coreclr/src/vm/appdomain.hpp
src/coreclr/src/vm/appdomainnative.cpp
src/coreclr/src/vm/callhelpers.cpp
src/coreclr/src/vm/ceemain.cpp
src/coreclr/src/vm/compile.cpp
src/coreclr/src/vm/corhost.cpp
src/coreclr/src/vm/ecalllist.h
src/coreclr/src/vm/metasig.h
src/coreclr/src/vm/mscorlib.h
src/coreclr/src/vm/object.h
src/coreclr/src/vm/vars.cpp
src/coreclr/src/vm/vars.hpp
src/coreclr/tests/CoreFX/CoreFX.issues.json
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs

index 83d712d..dcf61a0 100644 (file)
   <data name="UnauthorizedAccess_RegistryKeyGeneric_Key" xml:space="preserve">
     <value>Access to the registry key '{0}' is denied.</value>
   </data>
-  <data name="UnauthorizedAccess_SystemDomain" xml:space="preserve">
-    <value>Cannot execute an assembly in the system domain.</value>
-  </data>
   <data name="UnknownError_Num" xml:space="preserve">
     <value>Unknown error "{0}".</value>
   </data>
index a4d5573..c62827d 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\Marshal.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\PInvokeMap.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\PInvokeMarshal.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\RuntimeEnvironment.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\SEHException.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\SafeHandle.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\BStrWrapper.cs" />
     <Compile Include="$(BclSourcesRoot)\System\MulticastDelegate.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Activator.cs" />
     <Compile Include="$(BclSourcesRoot)\System\AppDomain.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\AppDomainSetup.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\AppDomainManager.cs" />
     <Compile Include="$(BclSourcesRoot)\System\AppDomainUnloadedException.cs" />
     <Compile Include="$(BclSourcesRoot)\System\ArgIterator.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Attribute.cs" />
index ebe3e29..4da4f36 100644 (file)
@@ -123,7 +123,7 @@ namespace System
             Assembly assembly = null;
             if (assemblyString == null)
             {
-                assembly = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
+                assembly = Assembly.GetExecutingAssembly(ref stackMark);
             }
             else
             {
index 7b8e436..3e192d5 100644 (file)
@@ -4,6 +4,7 @@
 
 
 using System.Collections.Generic;
+using System.IO;
 using System.Reflection;
 using System.Runtime.Versioning;
 
@@ -37,7 +38,15 @@ namespace System
             {
                 // The value of APP_CONTEXT_BASE_DIRECTORY key has to be a string and it is not allowed to be any other type. 
                 // Otherwise the caller will get invalid cast exception
-                return (string)AppDomain.CurrentDomain.GetData("APP_CONTEXT_BASE_DIRECTORY") ?? AppDomain.CurrentDomain.BaseDirectory;
+                string baseDirectory = (string)AppDomain.CurrentDomain.GetData("APP_CONTEXT_BASE_DIRECTORY");
+                if (baseDirectory != null)
+                    return baseDirectory;
+
+                // Fallback path for hosts that do not set APP_CONTEXT_BASE_DIRECTORY explicitly
+                string directory = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
+                if (directory != null && !PathInternal.EndsInDirectorySeparator(directory))
+                    directory += Path.DirectorySeparatorChar;
+                return directory;
             }
         }
 
index 874aca5..1d416fe 100644 (file)
@@ -28,9 +28,7 @@ namespace System
         // of these fields cannot be changed without changing the layout in
         // the EE- AppDomainBaseObject in this case)
 
-        private AppDomainManager _domainManager;
         private Dictionary<string, object> _LocalStore;
-        private AppDomainSetup _FusionStore;
         public event AssemblyLoadEventHandler AssemblyLoad;
 
         private ResolveEventHandler _TypeResolve;
@@ -102,18 +100,11 @@ namespace System
 
         private UnhandledExceptionEventHandler _unhandledException;
 
-        // The compat flags are set at domain creation time to indicate that the given breaking
-        // changes (named in the strings) should not be used in this domain. We only use the
-        // keys, the vhe values are ignored.
-        private Dictionary<string, object> _compatFlags;
-
         // Delegate that will hold references to FirstChance exception notifications
         private EventHandler<FirstChanceExceptionEventArgs> _firstChanceException;
 
         private IntPtr _pDomain;                      // this is an unmanaged pointer (AppDomain * m_pDomain)` used from the VM.
 
-        private bool _compatFlagsInitialized;
-
 #if FEATURE_APPX
         private static APPX_FLAGS s_flags;
 
@@ -151,9 +142,6 @@ namespace System
         /// </summary>
         private void CreateAppDomainManager()
         {
-            Debug.Assert(_domainManager == null, "_domainManager == null");
-
-            AppDomainSetup adSetup = FusionStore;
             string trustedPlatformAssemblies = (string)GetData("TRUSTED_PLATFORM_ASSEMBLIES");
             if (trustedPlatformAssemblies != null)
             {
@@ -163,29 +151,6 @@ namespace System
                 string appLocalWinMD = (string)GetData("APP_LOCAL_WINMETADATA") ?? string.Empty;
                 SetupBindingPaths(trustedPlatformAssemblies, platformResourceRoots, appPaths, appNiPaths, appLocalWinMD);
             }
-
-            InitializeCompatibilityFlags();
-        }
-
-        /// <summary>
-        ///     Initialize the compatibility flags to non-NULL values.
-        ///     This method is also called from the VM when the default domain doesn't have a domain manager.
-        /// </summary>
-        private void InitializeCompatibilityFlags()
-        {
-            AppDomainSetup adSetup = FusionStore;
-
-            // set up shim flags regardless of whether we create a DomainManager in this method.
-            if (adSetup.GetCompatibilityFlags() != null)
-            {
-                _compatFlags = new Dictionary<string, object>(adSetup.GetCompatibilityFlags(), StringComparer.OrdinalIgnoreCase);
-            }
-
-            // for perf, we don't intialize the _compatFlags dictionary when we don't need to.  However, we do need to make a
-            // note that we've run this method, because IsCompatibilityFlagsSet needs to return different values for the
-            // case where the compat flags have been setup.
-            Debug.Assert(!_compatFlagsInitialized);
-            _compatFlagsInitialized = true;
         }
 
         /// <summary>
@@ -237,12 +202,8 @@ namespace System
 #endif
         }
 
-        public AppDomainManager DomainManager => _domainManager;
-
         public static AppDomain CurrentDomain => Thread.GetDomain();
 
-        public string BaseDirectory => FusionStore.ApplicationBase;
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         private extern Assembly[] nGetAssemblies(bool forIntrospection);
 
@@ -289,9 +250,6 @@ namespace System
             Debug.Fail("Object cannot be created through this constructor.");
         }
 
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        internal extern void nCreateContext();
-
         [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
         private static extern void nSetupBindingPaths(string trustedPlatformAssemblies, string platformResourceRoots, string appPath, string appNiPaths, string appLocalWinMD);
 
@@ -432,15 +390,6 @@ namespace System
         }
 #endif // FEATURE_COMINTEROP
 
-        internal AppDomainSetup FusionStore
-        {
-            get
-            {
-                Debug.Assert(_FusionStore != null, "Fusion store has not been correctly setup in this domain");
-                return _FusionStore;
-            }
-        }
-
         private static RuntimeAssembly GetRuntimeAssembly(Assembly asm)
         {
             return
@@ -461,78 +410,11 @@ namespace System
         [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
         private static extern void nSetNativeDllSearchDirectories(string paths);
 
-        private void SetupFusionStore(AppDomainSetup info, AppDomainSetup oldInfo)
-        {
-            Debug.Assert(info != null);
-
-            if (info.ApplicationBase == null)
-            {
-                info.SetupDefaults(RuntimeEnvironment.GetModuleFileName(), imageLocationAlreadyNormalized: true);
-            }
-
-            nCreateContext();
-
-            // This must be the last action taken
-            _FusionStore = info;
-        }
-
-        // Used to switch into other AppDomain and call SetupRemoteDomain.
-        //   We cannot simply call through the proxy, because if there
-        //   are any remoting sinks registered, they can add non-mscorlib
-        //   objects to the message (causing an assembly load exception when
-        //   we try to deserialize it on the other side)
-        private static object PrepareDataForSetup(string friendlyName,
-                                                        AppDomainSetup setup,
-                                                        string[] propertyNames,
-                                                        string[] propertyValues)
-        {
-            var newSetup = new AppDomainSetup(setup);
-
-            // Remove the special AppDomainCompatSwitch entries from the set of name value pairs
-            // And add them to the AppDomainSetup
-            //
-            // This is only supported on CoreCLR through ICLRRuntimeHost2.CreateAppDomainWithManager
-            // Desktop code should use System.AppDomain.CreateDomain() or
-            // System.AppDomainManager.CreateDomain() and add the flags to the AppDomainSetup
-            var compatList = new List<string>();
-
-            if (propertyNames != null && propertyValues != null)
-            {
-                for (int i = 0; i < propertyNames.Length; i++)
-                {
-                    if (string.Equals(propertyNames[i], "AppDomainCompatSwitch", StringComparison.OrdinalIgnoreCase))
-                    {
-                        compatList.Add(propertyValues[i]);
-                        propertyNames[i] = null;
-                        propertyValues[i] = null;
-                    }
-                }
-
-                if (compatList.Count > 0)
-                {
-                    newSetup.SetCompatibilitySwitches(compatList);
-                }
-            }
-
-            return new object[]
-            {
-                friendlyName,
-                newSetup,
-                propertyNames,
-                propertyValues
-            };
-        } // PrepareDataForSetup
-
-        private static object Setup(object arg)
+        private static void Setup(string friendlyName,
+                                    string[] propertyNames,
+                                    string[] propertyValues)
         {
-            var args = (object[])arg;
-            var friendlyName = (string)args[0];
-            var setup = (AppDomainSetup)args[1];
-            var propertyNames = (string[])args[2]; // can contain null elements
-            var propertyValues = (string[])args[3]; // can contain null elements
-
             AppDomain ad = CurrentDomain;
-            var newSetup = new AppDomainSetup(setup);
 
             if (propertyNames != null && propertyValues != null)
             {
@@ -555,107 +437,17 @@ namespace System
 
                 for (int i = 0; i < propertyNames.Length; i++)
                 {
-                    if (propertyNames[i] == "APPBASE") // make sure in sync with Fusion
-                    {
-                        if (propertyValues[i] == null)
-                            throw new ArgumentNullException("APPBASE");
-
-                        if (PathInternal.IsPartiallyQualified(propertyValues[i]))
-                            throw new ArgumentException(SR.Argument_AbsolutePathRequired);
-
-                        newSetup.ApplicationBase = NormalizePath(propertyValues[i], fullCheck: true);
-                    }
-                    else if (propertyNames[i] == "TRUSTED_PLATFORM_ASSEMBLIES" ||
-                       propertyNames[i] == "PLATFORM_RESOURCE_ROOTS" ||
-                       propertyNames[i] == "APP_PATHS" ||
-                       propertyNames[i] == "APP_NI_PATHS")
-                    {
-                        string values = propertyValues[i];
-                        if (values == null)
-                            throw new ArgumentNullException(propertyNames[i]);
-
-                        ad.SetData(propertyNames[i], NormalizeAppPaths(values));
-                    }
-                    else if (propertyNames[i] != null)
+                    if (propertyNames[i] != null)
                     {
-                        ad.SetData(propertyNames[i], propertyValues[i]);     // just propagate
+                        ad.SetData(propertyNames[i], propertyValues[i]);
                     }
                 }
             }
 
-            ad.SetupFusionStore(newSetup, null); // makes FusionStore a ref to newSetup
-
-            // technically, we don't need this, newSetup refers to the same object as FusionStore
-            // but it's confusing since it isn't immediately obvious whether we have a ref or a copy
-            AppDomainSetup adSetup = ad.FusionStore;
-
             // set up the friendly name
             ad.nSetupFriendlyName(friendlyName);
 
             ad.CreateAppDomainManager(); // could modify FusionStore's object
-
-            return null;
-        }
-
-        private static string NormalizeAppPaths(string values)
-        {
-            int estimatedLength = values.Length + 1; // +1 for extra separator temporarily added at end
-            StringBuilder sb = StringBuilderCache.Acquire(estimatedLength);
-
-            for (int pos = 0; pos < values.Length; pos++)
-            {
-                string path;
-
-                int nextPos = values.IndexOf(Path.PathSeparator, pos);
-                if (nextPos == -1)
-                {
-                    path = values.Substring(pos);
-                    pos = values.Length - 1;
-                }
-                else
-                {
-                    path = values.Substring(pos, nextPos - pos);
-                    pos = nextPos;
-                }
-
-                // Skip empty directories
-                if (path.Length == 0)
-                    continue;
-
-                if (PathInternal.IsPartiallyQualified(path))
-                    throw new ArgumentException(SR.Argument_AbsolutePathRequired);
-
-                string appPath = NormalizePath(path, fullCheck: true);
-                sb.Append(appPath);
-                sb.Append(Path.PathSeparator);
-            }
-
-            // Strip the last separator
-            if (sb.Length > 0)
-            {
-                sb.Remove(sb.Length - 1, 1);
-            }
-
-            return StringBuilderCache.GetStringAndRelease(sb);
-        }
-
-        internal static string NormalizePath(string path, bool fullCheck) => Path.GetFullPath(path);
-
-        // This routine is called from unmanaged code to
-        // set the default fusion context.
-        private void SetupDomain(bool allowRedirects, string path, string configFile, string[] propertyNames, string[] propertyValues)
-        {
-            // It is possible that we could have multiple threads initializing
-            // the default domain. We will just take the winner of these two.
-            // (eg. one thread doing a com call and another doing attach for IJW)
-            lock (this)
-            {
-                if (_FusionStore == null)
-                {
-                    // always use internet permission set
-                    SetupFusionStore(new AppDomainSetup(), null);
-                }
-            }
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/AppDomainManager.cs b/src/coreclr/src/System.Private.CoreLib/src/System/AppDomainManager.cs
deleted file mode 100644 (file)
index f8ea51d..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-//
-// An AppDomainManager gives a hosting application the chance to 
-// participate in the creation and control the settings of new AppDomains.
-//
-
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Security;
-using System.Runtime.InteropServices;
-
-namespace System
-{
-    internal class AppDomainManager : MarshalByRefObject
-    {
-        public AppDomainManager() { }
-
-        public virtual void InitializeNewDomain(AppDomainSetup appDomainInfo)
-        {
-            // By default, InitializeNewDomain does nothing. AppDomain.CreateAppDomainManager relies on this fact.
-        }
-
-        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
-        private static extern void GetEntryAssembly(ObjectHandleOnStack retAssembly);
-
-        private Assembly m_entryAssembly = null;
-        public virtual Assembly EntryAssembly
-        {
-            get
-            {
-                // The default AppDomainManager sets the EntryAssembly depending on whether the
-                // AppDomain is a manifest application domain or not. In the first case, we parse
-                // the application manifest to find out the entry point assembly and return that assembly.
-                // In the second case, we maintain the old behavior by calling GetEntryAssembly().
-                if (m_entryAssembly == null)
-                {
-                    {
-                        RuntimeAssembly entryAssembly = null;
-                        GetEntryAssembly(JitHelpers.GetObjectHandleOnStack(ref entryAssembly));
-                        m_entryAssembly = entryAssembly;
-                    }
-                }
-                return m_entryAssembly;
-            }
-        }
-
-        internal static AppDomainManager CurrentAppDomainManager
-        {
-            get
-            {
-                return AppDomain.CurrentDomain.DomainManager;
-            }
-        }
-    }
-}
diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/AppDomainSetup.cs b/src/coreclr/src/System.Private.CoreLib/src/System/AppDomainSetup.cs
deleted file mode 100644 (file)
index f897e36..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.Versioning;
-using System.IO;
-
-namespace System
-{
-    internal sealed class AppDomainSetup
-    {
-        private string _appBase;
-
-        // A collection of strings used to indicate which breaking changes shouldn't be applied
-        // to an AppDomain. We only use the keys, the values are ignored.
-        private Dictionary<string, object> _CompatFlags;
-
-        internal AppDomainSetup(AppDomainSetup copy)
-        {
-            if (copy != null)
-            {
-                _appBase = copy._appBase;
-
-                if (copy._CompatFlags != null)
-                {
-                    SetCompatibilitySwitches(copy._CompatFlags.Keys);
-                }
-            }
-        }
-
-        public AppDomainSetup()
-        {
-        }
-
-        internal void SetupDefaults(string imageLocation, bool imageLocationAlreadyNormalized = false)
-        {
-            char[] sep = { '\\', '/' };
-            int i = imageLocation.LastIndexOfAny(sep);
-
-            if (i != -1)
-            {
-                string appBase = imageLocation.Substring(0, i + 1);
-
-                if (imageLocationAlreadyNormalized)
-                    _appBase = appBase;
-                else
-                    ApplicationBase = appBase;
-            }
-        }
-
-        public string ApplicationBase
-        {
-            get
-            {
-                return _appBase;
-            }
-
-            set
-            {
-                _appBase = (value == null || value.Length == 0)? null:Path.GetFullPath(value);
-            }
-        }
-        
-        // only needed by AppDomain.Setup(). Not really needed by users. 
-        internal Dictionary<string, object> GetCompatibilityFlags()
-        {
-            return _CompatFlags;
-        }
-
-        public void SetCompatibilitySwitches(IEnumerable<string> switches)
-        {
-            if (switches != null)
-            {
-                _CompatFlags = new Dictionary<string, object>();
-                foreach (string str in switches)
-                {
-                    _CompatFlags.Add(str, null);
-                }
-            }
-            else
-            {
-                _CompatFlags = null;
-            }
-        }
-    }
-}
index e18eef7..4703b8b 100644 (file)
@@ -5,9 +5,11 @@
 using System.Collections.Generic;
 using System.IO;
 using System.Configuration.Assemblies;
-using StackCrawlMark = System.Threading.StackCrawlMark;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 using System.Runtime.Loader;
+using StackCrawlMark = System.Threading.StackCrawlMark;
 
 namespace System.Reflection
 {
@@ -160,7 +162,6 @@ namespace System.Reflection
         // Loads the assembly with a COFF based IMAGE containing
         // an emitted assembly. The assembly is loaded into a fully isolated ALC with resolution fully deferred to the AssemblyLoadContext.Default.
         // The second parameter is the raw bytes representing the symbol store that matches the assembly.
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static Assembly Load(byte[] rawAssembly,
                                     byte[] rawSymbolStore)
         {
@@ -202,12 +203,22 @@ namespace System.Reflection
             return result;
         }
 
+        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+        private static extern void GetExecutingAssembly(StackCrawlMarkHandle stackMark, ObjectHandleOnStack retAssembly);
+
+        internal static RuntimeAssembly GetExecutingAssembly(ref StackCrawlMark stackMark)
+        {
+            RuntimeAssembly retAssembly = null;
+            GetExecutingAssembly(JitHelpers.GetStackCrawlMarkHandle(ref stackMark), JitHelpers.GetObjectHandleOnStack(ref retAssembly));
+            return retAssembly;
+        }
+
         // Get the assembly that the current code is running from.
         [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod 
         public static Assembly GetExecutingAssembly()
         {
             StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RuntimeAssembly.GetExecutingAssembly(ref stackMark);
+            return GetExecutingAssembly(ref stackMark);
         }
 
         [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
@@ -217,15 +228,23 @@ namespace System.Reflection
             // because of inlining, tail calls, etc. As a result GetCallingAssembly is not 
             // guaranteed to return the correct result. It's also documented as such.
             StackCrawlMark stackMark = StackCrawlMark.LookForMyCallersCaller;
-            return RuntimeAssembly.GetExecutingAssembly(ref stackMark);
+            return GetExecutingAssembly(ref stackMark);
         }
 
+        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+        private static extern void GetEntryAssembly(ObjectHandleOnStack retAssembly);
+
+        // internal test hook
+        private static bool s_forceNullEntryPoint = false;
+
         public static Assembly GetEntryAssembly()
         {
-            AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
-            if (domainManager == null)
-                domainManager = new AppDomainManager();
-            return domainManager.EntryAssembly;
+            if (s_forceNullEntryPoint)
+                return null;
+
+            RuntimeAssembly entryAssembly = null;
+            GetEntryAssembly(JitHelpers.GetObjectHandleOnStack(ref entryAssembly));
+            return entryAssembly;
         }
     }
 }
index 14330ae..0203244 100644 (file)
@@ -116,7 +116,7 @@ namespace System.Reflection.Emit
             throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
         }
 
-        public override string ImageRuntimeVersion => RuntimeEnvironment.GetSystemVersion();
+        public override string ImageRuntimeVersion => Assembly.GetExecutingAssembly().ImageRuntimeVersion;
 
         #endregion
     }
index deac03b..b43b0cc 100644 (file)
@@ -415,16 +415,6 @@ namespace System.Reflection
             return GetManifestResourceNames(GetNativeHandle());
         }
 
-        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
-        private static extern void GetExecutingAssembly(StackCrawlMarkHandle stackMark, ObjectHandleOnStack retAssembly);
-
-        internal static RuntimeAssembly GetExecutingAssembly(ref StackCrawlMark stackMark)
-        {
-            RuntimeAssembly retAssembly = null;
-            GetExecutingAssembly(JitHelpers.GetStackCrawlMarkHandle(ref stackMark), JitHelpers.GetObjectHandleOnStack(ref retAssembly));
-            return retAssembly;
-        }
-
         // Returns the names of all the resources
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         private static extern AssemblyName[] GetReferencedAssemblies(RuntimeAssembly assembly);
diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs
deleted file mode 100644 (file)
index 8afc470..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: Runtime information
-**          
-**
-=============================================================================*/
-
-using System;
-using System.Text;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Reflection;
-using Microsoft.Win32;
-using System.Runtime.Versioning;
-using StackCrawlMark = System.Threading.StackCrawlMark;
-
-namespace System.Runtime.InteropServices
-{
-    internal static class RuntimeEnvironment
-    {
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        internal static extern string GetModuleFileName();
-
-        public static string GetSystemVersion()
-        {
-            return Assembly.GetExecutingAssembly().ImageRuntimeVersion;
-        }
-    }
-}
index d395f4d..dc7b9ad 100644 (file)
@@ -28,6 +28,8 @@
 #include "utils.hpp"
 #include "variables.hpp"
 #include "ex.h"
+#include "clr/fs/path.h"
+using namespace clr::fs;
 
 namespace BINDER_SPACE
 {
@@ -258,17 +260,20 @@ namespace BINDER_SPACE
                 break;
             }
 
+#ifndef CROSSGEN_COMPILE
+            if (Path::IsRelative(fileName))
+            {
+                BINDER_LOG_STRING(W("ApplicationContext::SetupBindingPaths: Relative path not allowed"), fileName);
+                GO_WITH_HRESULT(E_INVALIDARG);
+            }
+#endif
+
             // Find the beginning of the simple name
             SString::Iterator iSimpleNameStart = fileName.End();
             
             if (!fileName.FindBack(iSimpleNameStart, DIRECTORY_SEPARATOR_CHAR_W))
             {
-#ifdef CROSSGEN_COMPILE
                 iSimpleNameStart = fileName.Begin();
-#else
-                // Couldn't find a directory separator.  File must have been specified as a relative path.  Not allowed.
-                GO_WITH_HRESULT(E_INVALIDARG);
-#endif
             }
             else
             {
@@ -395,6 +400,14 @@ namespace BINDER_SPACE
                 break;
             }
 
+#ifndef CROSSGEN_COMPILE
+            if (Path::IsRelative(pathName))
+            {
+                BINDER_LOG_STRING(W("ApplicationContext::SetupBindingPaths: Relative path not allowed"), pathName);
+                GO_WITH_HRESULT(E_INVALIDARG);
+            }
+#endif
+
             m_platformResourceRoots.Append(pathName);
             BINDER_LOG_STRING(W("ApplicationContext::SetupBindingPaths: Added resource root"), pathName);
         }
@@ -414,6 +427,14 @@ namespace BINDER_SPACE
                 break;
             }
             
+#ifndef CROSSGEN_COMPILE
+            if (Path::IsRelative(pathName))
+            {
+                BINDER_LOG_STRING(W("ApplicationContext::SetupBindingPaths: Relative path not allowed"), pathName);
+                GO_WITH_HRESULT(E_INVALIDARG);
+            }
+#endif
+
             m_appPaths.Append(pathName);
             BINDER_LOG_STRING(W("ApplicationContext::SetupBindingPaths: Added App Path"), pathName);
         }
@@ -433,6 +454,14 @@ namespace BINDER_SPACE
                 break;
             }
 
+#ifndef CROSSGEN_COMPILE
+            if (Path::IsRelative(pathName))
+            {
+                BINDER_LOG_STRING(W("ApplicationContext::SetupBindingPaths: Relative path not allowed"), pathName);
+                GO_WITH_HRESULT(E_INVALIDARG);
+            }
+#endif
+
             m_appNiPaths.Append(pathName);
             BINDER_LOG_STRING(W("ApplicationContext::SetupBindingPaths: Added App NI Path"), pathName);
         }
index 942ac3d..d525f87 100644 (file)
@@ -158,17 +158,9 @@ void QCALLTYPE SystemNative::_GetCommandLine(QCall::StringHandleOnStack retStrin
 
     LPCWSTR commandLine;
 
-    if (g_pCachedCommandLine != NULL)
-    {
-        // Use the cached command line if available
-        commandLine = g_pCachedCommandLine;
-    }
-    else
-    {
-        commandLine = WszGetCommandLine();
-        if (commandLine==NULL)
-            COMPlusThrowOM();
-    }
+    commandLine = WszGetCommandLine();
+    if (commandLine==NULL)
+        COMPlusThrowOM();
     
     retString.Set(commandLine);
 
@@ -185,17 +177,9 @@ FCIMPL0(Object*, SystemNative::GetCommandLineArgs)
 
     LPWSTR commandLine;
 
-    if (g_pCachedCommandLine != NULL)
-    {
-        // Use the cached command line if available
-        commandLine = g_pCachedCommandLine;
-    }
-    else
-    {
-        commandLine = WszGetCommandLine();
-        if (commandLine==NULL)
-            COMPlusThrowOM();
-    }
+    commandLine = WszGetCommandLine();
+    if (commandLine==NULL)
+        COMPlusThrowOM();
 
     DWORD numArgs = 0;
     LPWSTR* argv = SegmentCommandLine(commandLine, &numArgs);
@@ -250,64 +234,6 @@ FCIMPL1(ReflectMethodObject*, SystemNative::GetMethodFromStackTrace, ArrayBase*
 }
 FCIMPLEND
 
-FCIMPL0(StringObject*, SystemNative::_GetModuleFileName)
-{
-    FCALL_CONTRACT;
-
-    STRINGREF   refRetVal = NULL;
-
-    HELPER_METHOD_FRAME_BEGIN_RET_1(refRetVal);
-    if (g_pCachedModuleFileName)
-    {
-        refRetVal = StringObject::NewString(g_pCachedModuleFileName);
-    }
-    else
-    {
-        PathString wszFilePathString;
-
-       
-        DWORD lgth = WszGetModuleFileName(NULL, wszFilePathString);
-        if (!lgth)
-        {
-            COMPlusThrowWin32();
-        }
-       
-
-        refRetVal = StringObject::NewString(wszFilePathString.GetUnicode());
-    }
-    HELPER_METHOD_FRAME_END();
-
-    return (StringObject*)OBJECTREFToObject(refRetVal);
-}
-FCIMPLEND
-
-FCIMPL0(StringObject*, SystemNative::GetRuntimeDirectory)
-{
-    FCALL_CONTRACT;
-
-    STRINGREF   refRetVal   = NULL;
-    DWORD dwFile = MAX_LONGPATH+1;
-
-    HELPER_METHOD_FRAME_BEGIN_RET_1(refRetVal);
-    SString wszFilePathString;
-
-    WCHAR * wszFile = wszFilePathString.OpenUnicodeBuffer(dwFile);
-    HRESULT hr = GetInternalSystemDirectory(wszFile, &dwFile);
-    wszFilePathString.CloseBuffer(dwFile);
-    
-    if(FAILED(hr))
-        COMPlusThrowHR(hr);
-
-    dwFile--; // remove the trailing NULL
-
-    if(dwFile)
-        refRetVal = StringObject::NewString(wszFile, dwFile);
-
-    HELPER_METHOD_FRAME_END();
-    return (StringObject*)OBJECTREFToObject(refRetVal);
-}
-FCIMPLEND
-
 INT32 QCALLTYPE SystemNative::GetProcessorCount()
 {
     QCALL_CONTRACT;
index 9f985bf..9480ee9 100644 (file)
@@ -56,9 +56,6 @@ public:
     static FCDECL2(VOID, FailFastWithException, StringObject* refMessageUNSAFE, ExceptionObject* refExceptionUNSAFE);
     static FCDECL3(VOID, FailFastWithExceptionAndSource, StringObject* refMessageUNSAFE, ExceptionObject* refExceptionUNSAFE, StringObject* errorSourceUNSAFE);
 
-    static FCDECL0(StringObject*, _GetModuleFileName);
-    static FCDECL0(StringObject*, GetRuntimeDirectory);
-
     // Returns the number of logical processors that can be used by managed code
        static INT32 QCALLTYPE GetProcessorCount();
 
index bbbad02..8516f29 100644 (file)
@@ -2918,10 +2918,6 @@ void SystemDomain::ReleaseAppDomainId(ADID index)
 
 #if defined(FEATURE_COMINTEROP_APARTMENT_SUPPORT) && !defined(CROSSGEN_COMPILE)
 
-#ifdef _DEBUG
-int g_fMainThreadApartmentStateSet = 0;
-#endif
-
 Thread::ApartmentState SystemDomain::GetEntryPointThreadAptState(IMDInternalImport* pScope, mdMethodDef mdMethod)
 {
     STANDARD_VM_CONTRACT;
@@ -2972,10 +2968,6 @@ void SystemDomain::SetThreadAptState (Thread::ApartmentState state)
         Thread::ApartmentState pState = pThread->SetApartment(Thread::AS_InMTA, TRUE);
         _ASSERTE(pState == Thread::AS_InMTA);
     }
-
-#ifdef _DEBUG
-    g_fMainThreadApartmentStateSet++;
-#endif
 }
 #endif // defined(FEATURE_COMINTEROP_APARTMENT_SUPPORT) && !defined(CROSSGEN_COMPILE)
 
@@ -2990,139 +2982,6 @@ BOOL SystemDomain::SetGlobalSharePolicyUsingAttribute(IMDInternalImport* pScope,
     return FALSE;
 }
 
-void SystemDomain::SetupDefaultDomain()
-{
-    CONTRACT_VOID
-    {
-        THROWS;
-        GC_TRIGGERS;
-        MODE_ANY;
-        INJECT_FAULT(COMPlusThrowOM(););
-    }
-    CONTRACT_END;
-
-
-    Thread *pThread = GetThread();
-    _ASSERTE(pThread);
-
-    AppDomain *pDomain;
-    pDomain = pThread->GetDomain();
-    _ASSERTE(pDomain);
-
-    GCX_COOP();
-
-    ENTER_DOMAIN_PTR(SystemDomain::System()->DefaultDomain(),ADV_DEFAULTAD)
-    {
-        // Push this frame around loading the main assembly to ensure the
-        // debugger can properly recgonize any managed code that gets run
-        // as "class initializaion" code.
-        FrameWithCookie<DebuggerClassInitMarkFrame> __dcimf;
-
-        {
-            GCX_PREEMP();
-            InitializeDefaultDomain(TRUE);
-        }
-
-        __dcimf.Pop();
-    }
-    END_DOMAIN_TRANSITION;
-
-    RETURN;
-}
-
-HRESULT SystemDomain::SetupDefaultDomainNoThrow()
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        MODE_ANY;
-    }
-    CONTRACTL_END;
-
-    HRESULT hr = S_OK;
-
-    EX_TRY
-    {
-        SystemDomain::SetupDefaultDomain();
-    }
-    EX_CATCH_HRESULT(hr);
-
-    return hr;
-}
-
-#ifdef _DEBUG
-int g_fInitializingInitialAD = 0;
-#endif
-
-// This routine completes the initialization of the default domaine.
-// After this call mananged code can be executed.
-void SystemDomain::InitializeDefaultDomain(
-    BOOL allowRedirects,
-    ICLRPrivBinder * pBinder)
-{
-    STANDARD_VM_CONTRACT;
-
-    WCHAR* pwsConfig = NULL;
-    WCHAR* pwsPath = NULL;
-
-    ETWOnStartup (InitDefaultDomain_V1, InitDefaultDomainEnd_V1);
-
-
-    // Setup the default AppDomain.
-
-#ifdef _DEBUG
-    g_fInitializingInitialAD++;
-#endif
-
-    AppDomain* pDefaultDomain = SystemDomain::System()->DefaultDomain();
-
-    if (pBinder != nullptr)
-    {
-        pDefaultDomain->SetLoadContextHostBinder(pBinder);
-    }
-
-    {
-        GCX_COOP();
-
-        pDefaultDomain->InitializeDomainContext(allowRedirects, pwsPath, pwsConfig);
-
-#ifndef CROSSGEN_COMPILE
-        if (!NingenEnabled())
-        {
-    
-            if (!IsSingleAppDomain())
-            {
-                pDefaultDomain->InitializeDefaultDomainManager();
-            }
-        }
-#endif // CROSSGEN_COMPILE
-    }
-
-    // DefaultDomain Load event
-    ETW::LoaderLog::DomainLoad(pDefaultDomain);
-
-#ifdef _DEBUG
-    g_fInitializingInitialAD--;
-#endif
-
-    TESTHOOKCALL(RuntimeStarted(RTS_DEFAULTADREADY));
-}
-
-
-
-#ifndef CROSSGEN_COMPILE
-
-#ifdef _DEBUG
-Volatile<LONG> g_fInExecuteMainMethod = 0;
-#endif
-
-
-
-
-#endif // CROSSGEN_COMPILE
-
-
-
 // Helper function to load an assembly. This is called from LoadCOMClass.
 /* static */
 
@@ -4342,52 +4201,6 @@ OBJECTREF AppDomain::GetExposedObject()
     return ref;
 }
 
-
-
-OBJECTREF AppDomain::DoSetup(OBJECTREF* setupInfo)
-{
-    CONTRACTL
-    {
-        MODE_COOPERATIVE;
-        THROWS;
-        GC_TRIGGERS;
-        INJECT_FAULT(COMPlusThrowOM(););
-    }
-    CONTRACTL_END;
-
-    ADID adid=GetAppDomain()->GetId();
-
-    OBJECTREF retval=NULL;
-    GCPROTECT_BEGIN(retval);    
-
-    ENTER_DOMAIN_PTR(this,ADV_CREATING);
-
-    MethodDescCallSite setup(METHOD__APP_DOMAIN__SETUP);
-
-    ARG_SLOT args[1];
-
-    args[0]=ObjToArgSlot(*setupInfo);
-
-    OBJECTREF activator;
-    activator=setup.Call_RetOBJECTREF(args);
-    _ASSERTE(activator==NULL);
-    
-#if defined(FEATURE_MULTICOREJIT)
-    // Disable AutoStartProfile in default domain from this code path.
-    // It's called from SystemDomain::ExecuteMainMethod for normal program, not needed for SL and Asp.Net
-    if (! IsDefaultDomain())
-    {
-        GCX_PREEMP();
-
-        GetMulticoreJitManager().AutoStartProfile(this);
-    }
-#endif
-
-    END_DOMAIN_TRANSITION;
-    GCPROTECT_END();
-    return retval;
-}
-
 #endif // !CROSSGEN_COMPILE
 
 #ifdef FEATURE_COMINTEROP
@@ -7253,76 +7066,8 @@ AppDomain::RaiseUnhandledExceptionEvent(OBJECTREF *pSender, OBJECTREF *pThrowabl
     return result;
 }
 
-
-
 #endif // CROSSGEN_COMPILE
 
-// You must be in the correct context before calling this
-// routine. Therefore, it is only good for initializing the
-// default domain.
-void AppDomain::InitializeDomainContext(BOOL allowRedirects,
-                                        LPCWSTR pwszPath,
-                                        LPCWSTR pwszConfig)
-{
-    CONTRACTL
-    {
-        MODE_COOPERATIVE;
-        GC_TRIGGERS;
-        THROWS;
-        INJECT_FAULT(COMPlusThrowOM(););
-    }
-    CONTRACTL_END;
-
-    if (NingenEnabled())
-    {
-
-        CreateFusionContext();
-
-        return;
-    }
-
-#ifndef CROSSGEN_COMPILE
-    struct _gc {
-        STRINGREF pFilePath;
-        STRINGREF pConfig;
-        OBJECTREF ref;
-        PTRARRAYREF propertyNames;
-        PTRARRAYREF propertyValues;
-    } gc;
-    ZeroMemory(&gc, sizeof(gc));
-
-    GCPROTECT_BEGIN(gc);
-    if(pwszPath)
-    {
-        gc.pFilePath = StringObject::NewString(pwszPath);
-    }
-
-    if(pwszConfig)
-    {
-        gc.pConfig = StringObject::NewString(pwszConfig);
-    }
-
-
-    if ((gc.ref = GetExposedObject()) != NULL)
-    {
-        MethodDescCallSite setupDomain(METHOD__APP_DOMAIN__SETUP_DOMAIN);
-
-        ARG_SLOT args[] =
-        {
-            ObjToArgSlot(gc.ref),
-            BoolToArgSlot(allowRedirects),
-            ObjToArgSlot(gc.pFilePath),
-            ObjToArgSlot(gc.pConfig),
-            ObjToArgSlot(gc.propertyNames),
-            ObjToArgSlot(gc.propertyValues)
-        };
-        setupDomain.Call(args);
-    }
-    GCPROTECT_END();
-#endif // CROSSGEN_COMPILE
-}
-
-
 IUnknown *AppDomain::CreateFusionContext()
 {
     CONTRACT(IUnknown *)
@@ -8695,43 +8440,6 @@ AppDomain::RaiseAssemblyResolveEvent(
 } // AppDomain::RaiseAssemblyResolveEvent
 
 
-//---------------------------------------------------------------------------------------
-//
-// Determine the type of AppDomainManager to use for the default AppDomain
-//
-// Notes:
-//   v2.0 of the CLR used environment variables APPDOMAIN_MANAGER_ASM and APPDOMAIN_MANAGER_TYPE to set the
-//   domain manager. For compatibility these are still supported, along with appDomainManagerAsm and
-//   appDomainManagerType config file switches. If the config switches are supplied, the entry point must be
-//   fully trusted.  
-//
-
-void AppDomain::InitializeDefaultDomainManager()
-{
-    CONTRACTL
-    {
-        MODE_COOPERATIVE;
-        GC_TRIGGERS;
-        THROWS;
-        INJECT_FAULT(COMPlusThrowOM(););
-        PRECONDITION(GetId().m_dwId == DefaultADID);
-    }
-    CONTRACTL_END;
-
-    OBJECTREF orThis = GetExposedObject();
-    GCPROTECT_BEGIN(orThis);
-
-    MethodDescCallSite initCompatFlags(METHOD__APP_DOMAIN__INITIALIZE_COMPATIBILITY_FLAGS);
-    ARG_SLOT args[] =
-    {
-        ObjToArgSlot(orThis)
-    };
-
-    initCompatFlags.Call(args);
-
-    GCPROTECT_END();
-}
-
 ULONGLONG g_ObjFinalizeStartTime = 0;
 Volatile<BOOL> g_FinalizerIsRunning = FALSE;
 Volatile<ULONG> g_FinalizerLoopCount = 0;
index 03e2c87..3c60748 100644 (file)
@@ -1950,9 +1950,6 @@ public:
     virtual BOOL IsAppDomain() { LIMITED_METHOD_DAC_CONTRACT; return TRUE; }
     virtual PTR_AppDomain AsAppDomain() { LIMITED_METHOD_CONTRACT; return dac_cast<PTR_AppDomain>(this); }
 
-
-    OBJECTREF DoSetup(OBJECTREF* setupInfo);
-
     OBJECTREF GetExposedObject();
     OBJECTREF GetRawExposedObject() {
         CONTRACTL
@@ -2637,8 +2634,6 @@ public:
         return m_tpIndex;
     }
 
-    void InitializeDomainContext(BOOL allowRedirects, LPCWSTR pwszPath, LPCWSTR pwszConfig);
-
     IUnknown *CreateFusionContext();
 
     void OverrideDefaultContextBinder(IUnknown *pOverrideBinder)
@@ -3165,10 +3160,6 @@ private:
     DispIDCache* SetupRefDispIDCache();
 #endif // FEATURE_COMINTEROP
 
-    void InitializeDefaultDomainManager ();
-
-public:
-
 protected:
     BOOL PostBindResolveAssembly(AssemblySpec  *pPrePolicySpec,
                                  AssemblySpec  *pPostPolicySpec,
@@ -3923,12 +3914,6 @@ public:
     }
 #endif // DACCESS_COMPILE
 
-    static void ActivateApplication(int *pReturnValue);
-
-    static void InitializeDefaultDomain(BOOL allowRedirects, ICLRPrivBinder * pBinder = NULL);
-    static void SetupDefaultDomain();
-    static HRESULT SetupDefaultDomainNoThrow();
-
 #if defined(FEATURE_COMINTEROP_APARTMENT_SUPPORT) && !defined(CROSSGEN_COMPILE)
     static Thread::ApartmentState GetEntryPointThreadAptState(IMDInternalImport* pScope, mdMethodDef mdMethod);
     static void SetThreadAptState(Thread::ApartmentState state);
index 3b2a538..da78874 100644 (file)
@@ -102,34 +102,6 @@ FCIMPL2(void, AppDomainNative::SetupFriendlyName, AppDomainBaseObject* refThisUN
 }
 FCIMPLEND
 
-FCIMPL1(void,
-        AppDomainNative::CreateContext,
-        AppDomainBaseObject *refThisUNSAFE)
-{
-    FCALL_CONTRACT;
-
-    struct _gc
-    {
-        APPDOMAINREF refThis;
-    } gc;
-
-    gc.refThis = (APPDOMAINREF) refThisUNSAFE;
-
-    HELPER_METHOD_FRAME_BEGIN_PROTECT(gc);
-
-    AppDomain* pDomain = ValidateArg(gc.refThis);
-
-    if((BaseDomain*) pDomain == SystemDomain::System())
-    {
-        COMPlusThrow(kUnauthorizedAccessException, W("UnauthorizedAccess_SystemDomain"));
-    }
-
-    pDomain->CreateFusionContext();
-
-    HELPER_METHOD_FRAME_END();
-}
-FCIMPLEND
-
 void QCALLTYPE AppDomainNative::SetupBindingPaths(__in_z LPCWSTR wszTrustedPlatformAssemblies, __in_z LPCWSTR wszPlatformResourceRoots, __in_z LPCWSTR wszAppPaths, __in_z LPCWSTR wszAppNiPaths, __in_z LPCWSTR appLocalWinMD)
 {
     QCALL_CONTRACT;
index 61d6865..7b5396a 100644 (file)
@@ -324,12 +324,6 @@ void FillInRegTypeMap(int argOffset, CorElementType typ, BYTE * pMap)
 }
 #endif // CALLDESCR_REGTYPEMAP
 
-#if defined(_DEBUG) && defined(FEATURE_COMINTEROP)
-extern int g_fMainThreadApartmentStateSet;
-extern int g_fInitializingInitialAD;
-extern Volatile<LONG> g_fInExecuteMainMethod;
-#endif
-
 //*******************************************************************************
 #ifdef FEATURE_INTERPRETER
 void MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments, ARG_SLOT *pReturnValue, int cbReturnValue, bool transitionToPreemptive)
@@ -355,14 +349,6 @@ void MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments, ARG_SLOT *
         MODE_COOPERATIVE;
         PRECONDITION(GetAppDomain()->CheckCanExecuteManagedCode(m_pMD));
         PRECONDITION(m_pMD->CheckActivated());          // EnsureActive will trigger, so we must already be activated
-
-#ifdef FEATURE_COMINTEROP
-        // If we're an exe, then we must either be initializing the first AD, or have already setup the main thread's
-        //  COM apartment state.
-        // If you hit this assert, then you likely introduced code during startup that could inadvertently 
-        //  initialize the COM apartment state of the main thread before we set it based on the user attribute.
-        PRECONDITION(g_fInExecuteMainMethod ? (g_fMainThreadApartmentStateSet || g_fInitializingInitialAD) : TRUE);
-#endif // FEATURE_COMINTEROP
     }
     CONTRACTL_END;
 
index e961510..428e3cf 100644 (file)
@@ -240,9 +240,6 @@ static HRESULT GetThreadUICultureNames(__inout StringArrayList* pCultureNames);
 HRESULT EEStartup(COINITIEE fFlags);
 
 
-BOOL STDMETHODCALLTYPE ExecuteEXE(HMODULE hMod);
-BOOL STDMETHODCALLTYPE ExecuteEXE(__in LPWSTR pImageNameIn);
-
 #ifndef CROSSGEN_COMPILE
 static void InitializeGarbageCollector();
 
@@ -1160,11 +1157,6 @@ HRESULT EEStartup(COINITIEE fFlags)
     }
     PAL_ENDTRY
 
-#ifndef CROSSGEN_COMPILE
-    if(SUCCEEDED(g_EEStartupStatus) && (fFlags & COINITEE_MAIN) == 0)
-        g_EEStartupStatus = SystemDomain::SetupDefaultDomainNoThrow();
-#endif
-
     return g_EEStartupStatus;
 }
 
index 6cdcf67..b44dddb 100644 (file)
@@ -163,7 +163,7 @@ HRESULT CEECompileInfo::CreateDomain(ICorCompilationDomain **ppDomain,
 
         ENTER_DOMAIN_PTR(pCompilationDomain,ADV_COMPILATION)
         {
-            pCompilationDomain->InitializeDomainContext(TRUE, NULL, NULL);
+            pCompilationDomain->CreateFusionContext();
 
             pCompilationDomain->SetFriendlyName(W("Compilation Domain"));
             SystemDomain::System()->LoadDomain(pCompilationDomain);
index 1707908..7294f38 100644 (file)
@@ -728,6 +728,8 @@ HRESULT CorHost2::_CreateAppDomain(
     if (dwFlags & APPDOMAIN_FORCE_TRIVIAL_WAIT_OPERATIONS)
         pDomain->SetForceTrivialWaitOperations();
 
+    pDomain->CreateFusionContext();
+
     {
         GCX_COOP();
     
@@ -736,8 +738,6 @@ HRESULT CorHost2::_CreateAppDomain(
             STRINGREF friendlyName;
             PTRARRAYREF propertyNames;
             PTRARRAYREF propertyValues;
-            OBJECTREF setupInfo;
-            OBJECTREF adSetup;
         } _gc;
 
         ZeroMemory(&_gc,sizeof(_gc));
@@ -745,7 +745,7 @@ HRESULT CorHost2::_CreateAppDomain(
         GCPROTECT_BEGIN(_gc)
         _gc.friendlyName=StringObject::NewString(wszFriendlyName);
         
-        if(nProperties>0)
+        if (nProperties>0)
         {
             _gc.propertyNames = (PTRARRAYREF) AllocateObjectArray(nProperties, g_pStringClass);
             _gc.propertyValues= (PTRARRAYREF) AllocateObjectArray(nProperties, g_pStringClass);
@@ -759,24 +759,14 @@ HRESULT CorHost2::_CreateAppDomain(
             }
         }
 
-        MethodDescCallSite prepareDataForSetup(METHOD__APP_DOMAIN__PREPARE_DATA_FOR_SETUP);
+        MethodDescCallSite setup(METHOD__APP_DOMAIN__SETUP);
 
-        ARG_SLOT args[4];
+        ARG_SLOT args[3];
         args[0]=ObjToArgSlot(_gc.friendlyName);
-        args[1]=ObjToArgSlot(NULL);
-        args[2]=ObjToArgSlot(_gc.propertyNames);
-        args[3]=ObjToArgSlot(_gc.propertyValues);
-
-        _gc.setupInfo=prepareDataForSetup.Call_RetOBJECTREF(args);
-
-        //
-        // Get the new flag values and set it to the domain
-        //
-        PTRARRAYREF handleArrayObj = (PTRARRAYREF) ObjectToOBJECTREF(_gc.setupInfo);
-        _gc.adSetup = ObjectToOBJECTREF(handleArrayObj->GetAt(1));
-
+        args[1]=ObjToArgSlot(_gc.propertyNames);
+        args[2]=ObjToArgSlot(_gc.propertyValues);
 
-        pDomain->DoSetup(&_gc.setupInfo);
+        setup.Call(args);
         
         GCPROTECT_END();
 
index f7c5a79..b056eb9 100644 (file)
@@ -155,10 +155,6 @@ FCFuncStart(gEnvironmentFuncs)
     FCFuncElementSig("FailFast", &gsig_SM_Str_Exception_Str_RetVoid, SystemNative::FailFastWithExceptionAndSource)
 FCFuncEnd()
 
-FCFuncStart(gRuntimeEnvironmentFuncs)
-    FCFuncElement("GetModuleFileName", SystemNative::_GetModuleFileName)
-FCFuncEnd()
-
 FCFuncStart(gSerializationFuncs)
     FCFuncElement("nativeGetUninitializedObject", ReflectionSerialization::GetUninitializedObject)
 FCFuncEnd()
@@ -442,10 +438,6 @@ FCFuncStart(gCompatibilitySwitchFuncs)
 FCFuncEnd()
 
 
-FCFuncStart(gAppDomainManagerFuncs)
-    QCFuncElement("GetEntryAssembly", AssemblyNative::GetEntryAssembly)
-FCFuncEnd()
-
 FCFuncStart(gAppDomainFuncs)
     FCFuncElement("IsStringInterned", AppDomainNative::IsStringInterned)
 
@@ -454,7 +446,6 @@ FCFuncStart(gAppDomainFuncs)
 #endif
     FCFuncElement("nSetupFriendlyName", AppDomainNative::SetupFriendlyName)
     FCFuncElement("nGetAssemblies", AppDomainNative::GetAssemblies)
-    FCFuncElement("nCreateContext", AppDomainNative::CreateContext)
     FCFuncElement("GetId", AppDomainNative::GetId)
     FCFuncElement("GetOrInternString", AppDomainNative::GetOrInternString)
     QCFuncElement("nSetupBindingPaths", AppDomainNative::SetupBindingPaths)
@@ -512,12 +503,11 @@ FCFuncStart(gManifestBasedResourceGrovelerFuncs)
     QCFuncElement("GetNeutralResourcesLanguageAttribute", AssemblyNative::GetNeutralResourcesLanguageAttribute)
 FCFuncEnd()
 
-FCFuncStart(gAssemblyFuncs)
+FCFuncStart(gRuntimeAssemblyFuncs)
     QCFuncElement("GetFullName", AssemblyNative::GetFullName)
     QCFuncElement("GetLocation", AssemblyNative::GetLocation)
     QCFuncElement("GetResource", AssemblyNative::GetResource)
     QCFuncElement("GetCodeBase", AssemblyNative::GetCodeBase)
-    QCFuncElement("GetExecutingAssembly", AssemblyNative::GetExecutingAssembly)
     QCFuncElement("GetFlags", AssemblyNative::GetFlags)
     QCFuncElement("GetHashAlgorithm", AssemblyNative::GetHashAlgorithm)
     QCFuncElement("GetLocale", AssemblyNative::GetLocale)
@@ -568,6 +558,11 @@ FCFuncStart(gLoaderAllocatorFuncs)
     QCFuncElement("Destroy", LoaderAllocator::Destroy)
 FCFuncEnd()
 
+FCFuncStart(gAssemblyFuncs)
+    QCFuncElement("GetEntryAssembly", AssemblyNative::GetEntryAssembly)
+    QCFuncElement("GetExecutingAssembly", AssemblyNative::GetExecutingAssembly)
+FCFuncEnd()
+
 FCFuncStart(gAssemblyBuilderFuncs)
     FCFuncElement("nCreateDynamicAssembly", AppDomainNative::CreateDynamicAssembly)
     FCFuncElement("GetInMemoryAssemblyModule", AssemblyNative::GetInMemoryAssemblyModule)
@@ -1244,10 +1239,10 @@ FCFuncEnd()
 // The sorting is case-sensitive
 
 FCClassElement("AppDomain", "System", gAppDomainFuncs)
-FCClassElement("AppDomainManager", "System", gAppDomainManagerFuncs)
 FCClassElement("ArgIterator", "System", gVarArgFuncs)
 FCClassElement("Array", "System", gArrayFuncs)
 FCClassElement("ArrayWithOffset", "System.Runtime.InteropServices", gArrayWithOffsetFuncs)
+FCClassElement("Assembly", "System.Reflection", gAssemblyFuncs)
 FCClassElement("AssemblyBuilder", "System.Reflection.Emit", gAssemblyBuilderFuncs)
 
 FCClassElement("AssemblyExtensions", "System.Reflection.Metadata", gAssemblyExtensionsFuncs)
@@ -1330,11 +1325,10 @@ FCClassElement("RegistrationServices", "System.Runtime.InteropServices", gRegist
 #endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION
 #endif // FEATURE_COMINTEROP
 
-FCClassElement("RuntimeAssembly", "System.Reflection", gAssemblyFuncs)
+FCClassElement("RuntimeAssembly", "System.Reflection", gRuntimeAssemblyFuncs)
 #ifdef FEATURE_COMINTEROP    
 FCClassElement("RuntimeClass", "System.Runtime.InteropServices.WindowsRuntime", gRuntimeClassFuncs)
 #endif // FEATURE_COMINTEROP    
-FCClassElement("RuntimeEnvironment", "System.Runtime.InteropServices", gRuntimeEnvironmentFuncs)
 FCClassElement("RuntimeFieldHandle", "System", gCOMFieldHandleNewFuncs)
 FCClassElement("RuntimeHelpers", "System.Runtime.CompilerServices", gCompilerFuncs)
 FCClassElement("RuntimeImports", "System.Runtime", gRuntimeImportsFuncs)
index d62b7c6..5d899df 100644 (file)
@@ -543,7 +543,7 @@ DEFINE_METASIG_T(IM(LicenseInteropHelper_GetLicInfo, g(RT_TYPE_HANDLE) r(i) r(i)
 // App Domain related defines
 DEFINE_METASIG(IM(Bool_Str_Str_ArrStr_ArrStr_RetVoid, F s s a(s) a(s), v))
 DEFINE_METASIG_T(SM(Str_RetAppDomain, s, C(APP_DOMAIN)))
-DEFINE_METASIG_T(SM(Str_AppDomainSetup_ArrStr_ArrStr_RetObj, s C(APPDOMAIN_SETUP) a(s) a(s), j))
+DEFINE_METASIG(SM(Str_ArrStr_ArrStr_RetVoid, s a(s) a(s), v))
 #ifdef FEATURE_COMINTEROP
 // System.AppDomain.OnReflectionOnlyNamespaceResolveEvent
 DEFINE_METASIG_T(IM(Assembly_Str_RetArrAssembly, C(ASSEMBLY) s, a(C(ASSEMBLY))))
index b8262f8..7b9831c 100644 (file)
@@ -67,9 +67,7 @@ DEFINE_FIELD(ACCESS_VIOLATION_EXCEPTION, TARGET,            _target)
 DEFINE_FIELD(ACCESS_VIOLATION_EXCEPTION, ACCESSTYPE,        _accessType)
 
 DEFINE_CLASS_U(System,                 AppDomain,      AppDomainBaseObject)
-DEFINE_FIELD_U(_domainManager,             AppDomainBaseObject, m_pDomainManager)
 DEFINE_FIELD_U(_LocalStore,                AppDomainBaseObject, m_LocalStore)
-DEFINE_FIELD_U(_FusionStore,               AppDomainBaseObject, m_FusionTable)
 DEFINE_FIELD_U(AssemblyLoad,               AppDomainBaseObject, m_pAssemblyEventHandler)
 DEFINE_FIELD_U(_TypeResolve,               AppDomainBaseObject, m_pTypeEventHandler)
 DEFINE_FIELD_U(_ResourceResolve,           AppDomainBaseObject, m_pResourceEventHandler)
@@ -77,14 +75,11 @@ DEFINE_FIELD_U(_AssemblyResolve,           AppDomainBaseObject, m_pAsmResolveEve
 DEFINE_FIELD_U(_processExit,               AppDomainBaseObject, m_pProcessExitEventHandler)
 DEFINE_FIELD_U(_domainUnload,              AppDomainBaseObject, m_pDomainUnloadEventHandler)
 DEFINE_FIELD_U(_unhandledException,        AppDomainBaseObject, m_pUnhandledExceptionEventHandler)
-DEFINE_FIELD_U(_compatFlags,              AppDomainBaseObject, m_compatFlags)
 DEFINE_FIELD_U(_firstChanceException,      AppDomainBaseObject, m_pFirstChanceExceptionHandler)
 DEFINE_FIELD_U(_pDomain,                   AppDomainBaseObject, m_pDomain)
-DEFINE_FIELD_U(_compatFlagsInitialized,           AppDomainBaseObject, m_compatFlagsInitialized)
 
 DEFINE_CLASS(APP_DOMAIN,            System,                 AppDomain)
-DEFINE_METHOD(APP_DOMAIN,           PREPARE_DATA_FOR_SETUP,PrepareDataForSetup,SM_Str_AppDomainSetup_ArrStr_ArrStr_RetObj)
-DEFINE_METHOD(APP_DOMAIN,           SETUP,Setup,SM_Obj_RetObj)
+DEFINE_METHOD(APP_DOMAIN,           SETUP,Setup,SM_Str_ArrStr_ArrStr_RetVoid)
 DEFINE_METHOD(APP_DOMAIN,           ON_ASSEMBLY_LOAD,       OnAssemblyLoadEvent,        IM_Assembly_RetVoid)
 DEFINE_METHOD(APP_DOMAIN,           ON_RESOURCE_RESOLVE,    OnResourceResolveEvent,     IM_Assembly_Str_RetAssembly)
 DEFINE_METHOD(APP_DOMAIN,           ON_TYPE_RESOLVE,        OnTypeResolveEvent,         IM_Assembly_Str_RetAssembly)
@@ -92,8 +87,6 @@ DEFINE_METHOD(APP_DOMAIN,           ON_ASSEMBLY_RESOLVE,    OnAssemblyResolveEve
 #ifdef FEATURE_COMINTEROP
 DEFINE_METHOD(APP_DOMAIN,           ON_DESIGNER_NAMESPACE_RESOLVE, OnDesignerNamespaceResolveEvent, IM_Str_RetArrStr)
 #endif //FEATURE_COMINTEROP
-DEFINE_METHOD(APP_DOMAIN,           SETUP_DOMAIN,           SetupDomain,                IM_Bool_Str_Str_ArrStr_ArrStr_RetVoid)
-DEFINE_METHOD(APP_DOMAIN,           INITIALIZE_COMPATIBILITY_FLAGS, InitializeCompatibilityFlags,  IM_RetVoid)
 
 DEFINE_CLASS(CLEANUP_WORK_LIST_ELEMENT,     StubHelpers,            CleanupWorkListElement)
 
@@ -108,8 +101,6 @@ DEFINE_FIELD_U(typeKind,        TypeNameNative,             typeKind)
 
 #endif
 
-DEFINE_CLASS(APPDOMAIN_SETUP,       System,                 AppDomainSetup)
-
 DEFINE_CLASS(ARG_ITERATOR,          System,                 ArgIterator)
 DEFINE_CLASS_U(System,              ArgIterator,            VARARGS)  // Includes a SigPointer.
 DEFINE_METHOD(ARG_ITERATOR,         CTOR2,                  .ctor,                      IM_RuntimeArgumentHandle_PtrVoid_RetVoid)
index 01b0d48..1e10756 100644 (file)
@@ -1575,9 +1575,7 @@ class AppDomainBaseObject : public MarshalByRefObjectBaseObject
     // READ ME:
     // Modifying the order or fields of this object may require other changes to the
     //  classlib class definition of this object.
-    OBJECTREF    m_pDomainManager;     // AppDomainManager for host settings.
     OBJECTREF    m_LocalStore;
-    OBJECTREF    m_FusionTable;
     OBJECTREF    m_pAssemblyEventHandler; // Delegate for 'loading assembly' event
     OBJECTREF    m_pTypeEventHandler;     // Delegate for 'resolve type' event
     OBJECTREF    m_pResourceEventHandler; // Delegate for 'resolve resource' event
@@ -1586,12 +1584,9 @@ class AppDomainBaseObject : public MarshalByRefObjectBaseObject
     OBJECTREF    m_pDomainUnloadEventHandler; // Delegate for 'about to unload domain' event
     OBJECTREF    m_pUnhandledExceptionEventHandler; // Delegate for 'unhandled exception' event
 
-    OBJECTREF    m_compatFlags;
-
     OBJECTREF    m_pFirstChanceExceptionHandler; // Delegate for 'FirstChance Exception' event
 
     AppDomain*   m_pDomain;            // Pointer to the BaseDomain Structure
-    CLR_BOOL     m_compatFlagsInitialized;
 
   protected:
     AppDomainBaseObject() { LIMITED_METHOD_CONTRACT; }
@@ -1610,12 +1605,6 @@ class AppDomainBaseObject : public MarshalByRefObjectBaseObject
         return m_pDomain;
     }
 
-    OBJECTREF GetAppDomainManager()
-    {
-        LIMITED_METHOD_CONTRACT;
-        return m_pDomainManager;
-    }
-
     // Returns the reference to the delegate of the first chance exception notification handler
     OBJECTREF GetFirstChanceExceptionNotificationHandler()
     {
index 0dbdee8..179acda 100644 (file)
@@ -229,11 +229,6 @@ bool dbg_fDrasticShutdown = false;
 bool g_fInControlC = false;
 
 //
-// Cached command line file provided by the host.
-//
-LPWSTR g_pCachedCommandLine = NULL;
-LPWSTR g_pCachedModuleFileName = 0;
-
 //
 // IJW needs the shim HINSTANCE
 //
index a062f0b..931bf3a 100644 (file)
@@ -584,12 +584,6 @@ EXTERN bool g_fInControlC;
 extern const DWORD g_rgPrimes[71];
 
 //
-// Cached command line file provided by the host.
-//
-extern LPWSTR g_pCachedCommandLine;
-extern LPWSTR g_pCachedModuleFileName;
-
-//
 // Macros to check debugger and profiler settings.
 //
 inline bool CORDebuggerPendingAttach()
index 7e317fa..75c0542 100644 (file)
@@ -1,5 +1,19 @@
 [
     {
+        "name": "System.Diagnostics.TraceSource.Tests",
+        "enabled": true,
+        "exclusions": {
+            "namespaces": null,
+            "classes": null,
+            "methods": [
+                {
+                    "name": "System.Diagnostics.TraceSourceTests.DefaultTraceListenerClassTests.EntryAssemblyName_Null_NotIncludedInTrace",
+                    "reason": "outdated"
+                }
+            ]
+        }
+    },
+    {
         "name": "System.Globalization.Tests",
         "enabled": true,
         "exclusions": {
index d2ecd63..7b8898e 100644 (file)
@@ -5672,19 +5672,11 @@ namespace System.Diagnostics.Tracing
                 cultures = new List<CultureInfo>();
                 cultures.Add(CultureInfo.CurrentUICulture);
             }
-#if ES_BUILD_STANDALONE || ES_BUILD_PN
-            var sortedStrings = new List<string>(stringTab.Keys);
-            sortedStrings.Sort();
-#else
-            // DD 947936
+
             var sortedStrings = new string[stringTab.Keys.Count];
             stringTab.Keys.CopyTo(sortedStrings, 0);
-            // Avoid using public Array.Sort as that attempts to access BinaryCompatibility. Unfortunately FrameworkEventSource gets called 
-            // very early in the app domain creation, when _FusionStore is not set up yet, resulting in a failure to run the static constructory
-            // for BinaryCompatibility. This failure is then cached and a TypeInitializationException is thrown every time some code attampts to
-            // access BinaryCompatibility.
-            ArraySortHelper<string>.IntrospectiveSort(sortedStrings, 0, sortedStrings.Length, string.Compare);
-#endif
+            Array.Sort<string>(sortedStrings, 0, sortedStrings.Length);
+
             foreach (var ci in cultures)
             {
                 sb.Append(" <resources culture=\"").Append(ci.Name).Append("\">").AppendLine();