}
else
{
- RuntimeAssembly? assemblyFromResolveEvent;
- AssemblyName assemblyName = RuntimeAssembly.CreateAssemblyName(assemblyString, out assemblyFromResolveEvent);
- if (assemblyFromResolveEvent != null)
- {
- // Assembly was resolved via AssemblyResolve event
- assembly = assemblyFromResolveEvent;
- }
- else if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime)
+ AssemblyName assemblyName = new AssemblyName(assemblyString);
+
+ if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime)
{
// WinRT type - we have to use Type.GetType
type = Type.GetType(typeName + ", " + assemblyString, true /*throwOnError*/, ignoreCase);
public static Assembly Load(byte[] rawAssembly) => Load(rawAssembly, rawSymbolStore: null);
- [Obsolete("This method has been deprecated. Please use Assembly.Load() instead. https://go.microsoft.com/fwlink/?linkid=14202")]
- public static Assembly LoadWithPartialName(string partialName)
- {
- if (partialName == null)
- throw new ArgumentNullException(nameof(partialName));
-
- if ((partialName.Length == 0) || (partialName[0] == '\0'))
- throw new ArgumentException(SR.Format_StringZeroLength, nameof(partialName));
-
- try
- {
- return Load(partialName);
- }
- catch (FileNotFoundException)
- {
- return null;
- }
- }
-
// 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.
// See the LICENSE file in the project root for more information.
#nullable enable
+using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
return RuntimeAssembly.InternalLoad(assemblyString, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext);
}
+ [Obsolete("This method has been deprecated. Please use Assembly.Load() instead. https://go.microsoft.com/fwlink/?linkid=14202")]
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ public static Assembly? LoadWithPartialName(string partialName)
+ {
+ if (partialName == null)
+ throw new ArgumentNullException(nameof(partialName));
+
+ if ((partialName.Length == 0) || (partialName[0] == '\0'))
+ throw new ArgumentException(SR.Format_StringZeroLength, nameof(partialName));
+
+ try
+ {
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+ return RuntimeAssembly.InternalLoad(partialName, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext);
+ }
+ catch (FileNotFoundException)
+ {
+ return null;
+ }
+ }
+
// 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
throw new ArgumentException(SR.Format_StringZeroLength);
_name = assemblyName;
- nInit(out RuntimeAssembly? dummy, false);
+ nInit();
}
internal AssemblyName(string? name,
}
[MethodImpl(MethodImplOptions.InternalCall)]
- internal extern void nInit(out RuntimeAssembly? assembly, bool raiseResolveEvent);
+ internal extern void nInit();
// This call opens and closes the file, but does not add the
// assembly to the domain.
internal static RuntimeAssembly InternalLoad(string assemblyString, ref StackCrawlMark stackMark, AssemblyLoadContext? assemblyLoadContext = null)
{
- RuntimeAssembly? assembly;
- AssemblyName an = CreateAssemblyName(assemblyString, out assembly);
-
- if (assembly != null)
- {
- // The assembly was returned from ResolveAssemblyEvent
- return assembly;
- }
+ AssemblyName an = new AssemblyName(assemblyString);
return InternalLoadAssemblyName(an, ref stackMark, assemblyLoadContext);
}
- // Creates AssemblyName. Fills assembly if AssemblyResolve event has been raised.
- internal static AssemblyName CreateAssemblyName(
- string assemblyString,
- out RuntimeAssembly? assemblyFromResolveEvent)
- {
- if (assemblyString == null)
- throw new ArgumentNullException(nameof(assemblyString));
-
- if ((assemblyString.Length == 0) ||
- (assemblyString[0] == '\0'))
- throw new ArgumentException(SR.Format_StringZeroLength);
-
- AssemblyName an = new AssemblyName();
-
- an.Name = assemblyString;
- an.nInit(out assemblyFromResolveEvent, true);
-
- return an;
- }
-
internal static RuntimeAssembly InternalLoadAssemblyName(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext? assemblyLoadContext = null)
{
#if FEATURE_APPX
FCIMPLEND
-FCIMPL3(void, AssemblyNameNative::Init, Object * refThisUNSAFE, OBJECTREF * pAssemblyRef, CLR_BOOL fRaiseResolveEvent)
+FCIMPL1(void, AssemblyNameNative::Init, Object * refThisUNSAFE)
{
FCALL_CONTRACT;
HELPER_METHOD_FRAME_BEGIN_1(pThis);
- *pAssemblyRef = NULL;
-
if (pThis == NULL)
COMPlusThrow(kNullReferenceException, W("NullReference_This"));
{
spec.AssemblyNameInit(&pThis,NULL);
}
- else if ((hr == FUSION_E_INVALID_NAME) && fRaiseResolveEvent)
- {
- Assembly * pAssembly = GetAppDomain()->RaiseAssemblyResolveEvent(&spec);
-
- if (pAssembly == NULL)
- {
- EEFileLoadException::Throw(&spec, hr);
- }
- else
- {
- *((OBJECTREF *) (&(*pAssemblyRef))) = pAssembly->GetExposedObject();
- }
- }
else
{
ThrowHR(hr);
static FCDECL1(Object*, ToString, Object* refThisUNSAFE);
static FCDECL1(Object*, GetPublicKeyToken, Object* refThisUNSAFE);
static FCDECL1(Object*, EscapeCodeBase, StringObject* filenameUNSAFE);
- static FCDECL3(void, Init, Object * refThisUNSAFE, OBJECTREF * pAssemblyRef, CLR_BOOL fRaiseResolveEvent);
+ static FCDECL1(void, Init, Object * refThisUNSAFE);
};
#endif // _AssemblyName_H
"name": "System.Tests.VersionTests.Comparisons_NullArgument_ThrowsArgumentNullException",
"reason": "Version was improved to no longer throw from comparison operators"
},
+ {
+ "name" : "System.Tests.ActivatorNetcoreTests.CreateInstanceAssemblyResolve",
+ "reason" : "Waiting for https://github.com/dotnet/corefx/pull/37080"
+ }
]
}
},