return StringBuilderCache.GetStringAndRelease(sb);
}
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private extern Assembly[] nGetAssemblies(bool forIntrospection);
+
+ internal Assembly[] GetAssemblies(bool forIntrospection)
+ {
+ return nGetAssemblies(forIntrospection);
+ }
+
// this is true when we've removed the handles etc so really can't do anything
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern bool IsUnloadingForcedFinalize();
[SuppressUnmanagedCodeSecurity]
private static extern void LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, string ilPath, string niPath, ObjectHandleOnStack retAssembly);
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void GetLoadedAssembliesInternal(ObjectHandleOnStack assemblies);
-
public static Assembly[] GetLoadedAssemblies()
{
- Assembly[] assemblies = null;
- GetLoadedAssembliesInternal(JitHelpers.GetObjectHandleOnStack(ref assemblies));
- return assemblies;
+ return AppDomain.CurrentDomain.GetAssemblies(false);
}
// These are helpers that can be used by AssemblyLoadContext derivations.
RETURN pLoadedAssembly;
}
-/* static */
-void QCALLTYPE AssemblyNative::GetLoadedAssembliesInternal(QCall::ObjectHandleOnStack assemblies)
-{
- QCALL_CONTRACT;
-
- BEGIN_QCALL;
-
- MethodTable * pAssemblyClass = MscorlibBinder::GetClass(CLASS__ASSEMBLY);
-
- PTR_AppDomain pCurDomain = GetAppDomain();
-
- SetSHash<PTR_DomainAssembly> assemblySet;
- pCurDomain->GetCacheAssemblyList(assemblySet);
- size_t nArrayElems = assemblySet.GetCount();
- PTRARRAYREF AsmArray = NULL;
-
- GCX_COOP();
-
- GCPROTECT_BEGIN(AsmArray);
- AsmArray = (PTRARRAYREF) AllocateObjectArray( (DWORD)nArrayElems, pAssemblyClass);
- for(auto it = assemblySet.Begin(); it != assemblySet.End(); it++)
- {
- PTR_DomainAssembly assem = *it;
- OBJECTREF o = (OBJECTREF)assem->GetExposedAssemblyObject();
- _ASSERTE(o != NULL);
- _ASSERTE(nArrayElems > 0);
- AsmArray->SetAt(--nArrayElems, o);
- }
-
- assemblies.Set(AsmArray);
-
- GCPROTECT_END();
-
- END_QCALL;
-}
-
/* static */
void QCALLTYPE AssemblyNative::LoadFromPath(INT_PTR ptrNativeAssemblyLoadContext, LPCWSTR pwzILPath, LPCWSTR pwzNIPath, QCall::ObjectHandleOnStack retLoadedAssembly)
{
static BOOL QCALLTYPE OverrideDefaultAssemblyLoadContextForCurrentDomain(INT_PTR ptrNativeAssemblyLoadContext);
static BOOL QCALLTYPE CanUseAppPathAssemblyLoadContextInCurrentDomain();
static void QCALLTYPE LoadFromPath(INT_PTR ptrNativeAssemblyLoadContext, LPCWSTR pwzILPath, LPCWSTR pwzNIPath, QCall::ObjectHandleOnStack retLoadedAssembly);
- static void QCALLTYPE GetLoadedAssembliesInternal(QCall::ObjectHandleOnStack assemblies);
static INT_PTR QCALLTYPE InternalLoadUnmanagedDllFromPath(LPCWSTR unmanagedLibraryPath);
static void QCALLTYPE LoadFromStream(INT_PTR ptrNativeAssemblyLoadContext, INT_PTR ptrAssemblyArray, INT32 cbAssemblyArrayLength, INT_PTR ptrSymbolArray, INT32 cbSymbolArrayLength, QCall::ObjectHandleOnStack retLoadedAssembly);
static Assembly* LoadFromPEImage(ICLRPrivBinder* pBinderContext, PEImage *pILImage, PEImage *pNIImage);
#if FEATURE_COMINTEROP
FCFuncElement("nSetDisableInterfaceCache", AppDomainNative::SetDisableInterfaceCache)
#endif // FEATURE_COMINTEROP
+ FCFuncElement("nGetAssemblies", AppDomainNative::GetAssemblies)
FCFuncElement("nCreateContext", AppDomainNative::CreateContext)
FCFuncElement("GetId", AppDomainNative::GetId)
FCFuncElement("GetOrInternString", AppDomainNative::GetOrInternString)
FCFuncStart(gAssemblyLoadContextFuncs)
QCFuncElement("InitializeAssemblyLoadContext", AssemblyNative::InitializeAssemblyLoadContext)
QCFuncElement("LoadFromPath", AssemblyNative::LoadFromPath)
- QCFuncElement("GetLoadedAssembliesInternal", AssemblyNative::GetLoadedAssembliesInternal)
QCFuncElement("InternalLoadUnmanagedDllFromPath", AssemblyNative::InternalLoadUnmanagedDllFromPath)
QCFuncElement("CanUseAppPathAssemblyLoadContextInCurrentDomain", AssemblyNative::CanUseAppPathAssemblyLoadContextInCurrentDomain)
QCFuncElement("LoadFromStream", AssemblyNative::LoadFromStream)