[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly Load(AssemblyName assemblyRef)
{
- AssemblyName modifiedAssemblyRef = null;
- if (assemblyRef != null && assemblyRef.CodeBase != null)
- {
- modifiedAssemblyRef = (AssemblyName)assemblyRef.Clone();
- modifiedAssemblyRef.CodeBase = null;
- }
- else
- {
- modifiedAssemblyRef = assemblyRef;
- }
-
+ if (assemblyRef == null)
+ throw new ArgumentNullException(nameof(assemblyRef));
+
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoadAssemblyName(modifiedAssemblyRef, null, ref stackMark, true /*thrownOnFileNotFound*/);
+ return Load(assemblyRef, ref stackMark, IntPtr.Zero);
}
// Locate an assembly by its name. The name can be strong or
// weak. The assembly is loaded into the domain of the caller.
- [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
- internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
+ internal static Assembly Load(AssemblyName assemblyRef, ref StackCrawlMark stackMark, IntPtr ptrLoadContextBinder)
{
AssemblyName modifiedAssemblyRef = null;
- if (assemblyRef != null && assemblyRef.CodeBase != null)
+ if (assemblyRef.CodeBase != null)
{
modifiedAssemblyRef = (AssemblyName)assemblyRef.Clone();
modifiedAssemblyRef.CodeBase = null;
modifiedAssemblyRef = assemblyRef;
}
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoadAssemblyName(modifiedAssemblyRef, null, ref stackMark, true /*thrownOnFileNotFound*/, ptrLoadContextBinder);
+ return RuntimeAssembly.InternalLoadAssemblyName(modifiedAssemblyRef, ref stackMark, ptrLoadContextBinder);
}
// Loads the assembly with a COFF based IMAGE containing
return CustomAttributeData.GetCustomAttributesInternal(this);
}
- // Wrapper function to wrap the typical use of InternalLoad.
- internal static RuntimeAssembly InternalLoad(string assemblyString,
- ref StackCrawlMark stackMark)
- {
- return InternalLoad(assemblyString, ref stackMark, IntPtr.Zero);
- }
-
- [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
- internal static RuntimeAssembly InternalLoad(string assemblyString,
- ref StackCrawlMark stackMark,
- IntPtr pPrivHostBinder)
+ internal static RuntimeAssembly InternalLoad(string assemblyString, ref StackCrawlMark stackMark)
{
RuntimeAssembly assembly;
AssemblyName an = CreateAssemblyName(assemblyString, out assembly);
return assembly;
}
- return InternalLoadAssemblyName(an, null, ref stackMark,
- pPrivHostBinder,
- true /*thrownOnFileNotFound*/);
+ return InternalLoadAssemblyName(an, ref stackMark);
}
// Creates AssemblyName. Fills assembly if AssemblyResolve event has been raised.
return an;
}
- // Wrapper function to wrap the typical use of InternalLoadAssemblyName.
- internal static RuntimeAssembly InternalLoadAssemblyName(
- AssemblyName assemblyRef,
- RuntimeAssembly reqAssembly,
- ref StackCrawlMark stackMark,
- bool throwOnFileNotFound,
- IntPtr ptrLoadContextBinder = default)
- {
- return InternalLoadAssemblyName(assemblyRef, reqAssembly, ref stackMark, IntPtr.Zero, throwOnFileNotFound, ptrLoadContextBinder);
- }
-
- internal static RuntimeAssembly InternalLoadAssemblyName(
- AssemblyName assemblyRef,
- RuntimeAssembly reqAssembly,
- ref StackCrawlMark stackMark,
- IntPtr pPrivHostBinder,
- bool throwOnFileNotFound,
- IntPtr ptrLoadContextBinder = default)
+ internal static RuntimeAssembly InternalLoadAssemblyName(AssemblyName assemblyRef, ref StackCrawlMark stackMark, IntPtr ptrLoadContextBinder = default)
{
- if (assemblyRef == null)
- throw new ArgumentNullException(nameof(assemblyRef));
-
#if FEATURE_APPX
if (ApplicationModel.IsUap)
{
string codeBase = VerifyCodeBase(assemblyRef.CodeBase);
- return nLoad(assemblyRef, codeBase, reqAssembly, ref stackMark,
- pPrivHostBinder,
- throwOnFileNotFound, ptrLoadContextBinder);
+ return nLoad(assemblyRef, codeBase, null, ref stackMark, true, ptrLoadContextBinder);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern RuntimeAssembly nLoad(AssemblyName fileName,
string codeBase,
- RuntimeAssembly locationHint,
+ RuntimeAssembly assemblyContext,
ref StackCrawlMark stackMark,
- IntPtr pPrivHostBinder,
bool throwOnFileNotFound,
- IntPtr ptrLoadContextBinder = default);
+ IntPtr ptrLoadContextBinder);
public override bool ReflectionOnly
{
Version version,
bool throwOnFileNotFound)
{
- // This stack crawl mark is never used because the requesting assembly is explicitly specified,
- // so the value could be anything.
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
AssemblyName an = new AssemblyName();
an.SetPublicKey(GetPublicKey());
an.CultureInfo = culture;
an.Name = GetSimpleName() + ".resources";
- RuntimeAssembly retAssembly = nLoad(an, null, this, ref stackMark,
- IntPtr.Zero,
- throwOnFileNotFound);
+ // This stack crawl mark is never used because the requesting assembly is explicitly specified,
+ // so the value could be anything.
+ StackCrawlMark unused = default;
+ RuntimeAssembly retAssembly = nLoad(an, null, this, ref unused, throwOnFileNotFound, IntPtr.Zero);
if (retAssembly == this)
{
-FCIMPL7(Object*, AssemblyNative::Load, AssemblyNameBaseObject* assemblyNameUNSAFE,
+FCIMPL6(Object*, AssemblyNative::Load, AssemblyNameBaseObject* assemblyNameUNSAFE,
StringObject* codeBaseUNSAFE,
AssemblyBaseObject* requestingAssemblyUNSAFE,
StackCrawlMark* stackMark,
- ICLRPrivBinder * pPrivHostBinder,
CLR_BOOL fThrowOnFileNotFound,
INT_PTR ptrLoadContextBinder)
{
EEFileLoadException::Throw(&spec, COR_E_NOTSUPPORTED);
}
- if (pPrivHostBinder != NULL)
- {
- pParentAssembly = NULL;
- spec.SetHostBinder(pPrivHostBinder);
- }
-
if (gc.codeBase != NULL)
spec.SetCodeBase(&(pThread->m_MarshalAlloc), &gc.codeBase);