In function Assembly.Load ignore AssemblyName.CodeBase even if it is set (dotnet...
authorRahul Kumar <rahku@microsoft.com>
Mon, 17 Apr 2017 18:47:47 +0000 (11:47 -0700)
committerGitHub <noreply@github.com>
Mon, 17 Apr 2017 18:47:47 +0000 (11:47 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/e82d10df9dd3de87d575ab488f320287f2d5f61b

src/coreclr/src/mscorlib/Resources/Strings.resx
src/coreclr/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs

index cb9474f..84c1cfc 100644 (file)
   <data name="NotSupported_AppX" xml:space="preserve">
     <value>{0} is not supported in AppX.</value>
   </data>
-  <data name="NotSupported_AssemblyLoadCodeBase" xml:space="preserve">
-    <value>Assembly.Load with a Codebase is not supported.</value>
-  </data>
   <data name="NotSupported_AssemblyLoadFromHash" xml:space="preserve">
     <value>Assembly.LoadFrom with hashValue is not supported.</value>
   </data>
index 82966db..708f79b 100644 (file)
@@ -101,14 +101,20 @@ namespace System.Reflection
         {
             Contract.Ensures(Contract.Result<Assembly>() != null);
             Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
+            
+            AssemblyName modifiedAssemblyRef = null;
             if (assemblyRef != null && assemblyRef.CodeBase != null)
             {
-                throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase);
+                modifiedAssemblyRef = (AssemblyName)assemblyRef.Clone();
+                modifiedAssemblyRef.CodeBase = null;
             }
-
+            else
+            {
+                modifiedAssemblyRef = assemblyRef;
+            }
+            
             StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
+            return RuntimeAssembly.InternalLoadAssemblyName(modifiedAssemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
         }
 
         // Locate an assembly by its name. The name can be strong or
@@ -119,13 +125,19 @@ namespace System.Reflection
             Contract.Ensures(Contract.Result<Assembly>() != null);
             Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
 
+            AssemblyName modifiedAssemblyRef = null;
             if (assemblyRef != null && assemblyRef.CodeBase != null)
             {
-                throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase);
+                modifiedAssemblyRef = (AssemblyName)assemblyRef.Clone();
+                modifiedAssemblyRef.CodeBase = null;
+            }
+            else
+            {
+                modifiedAssemblyRef = assemblyRef;
             }
 
             StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, ptrLoadContextBinder);
+            return RuntimeAssembly.InternalLoadAssemblyName(modifiedAssemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, ptrLoadContextBinder);
         }
 
         // Loads the assembly with a COFF based IMAGE containing