diff options
author | Steve MacLean <stmaclea@microsoft.com> | 2019-05-08 22:33:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-08 22:33:10 -0400 |
commit | 597e5faa03773e3140850d16381c00a6f9d20335 (patch) | |
tree | 68b82458b0f0774ea8363cfef13aeea513450d8e /src/vm | |
parent | 93ec324ee831cd4db087ae985c5b3a814ba8abb3 (diff) | |
download | coreclr-597e5faa03773e3140850d16381c00a6f9d20335.tar.gz coreclr-597e5faa03773e3140850d16381c00a6f9d20335.tar.bz2 coreclr-597e5faa03773e3140850d16381c00a6f9d20335.zip |
Remove premature throw (#24450)
* Remove premature throw
ResolveUsingEvent is no longer the last resort for Assembly resolution
and should not be throwing simply because the Assembly.Resolve event did
not find the Assembly
* Delay throw FileNotFound until after AppDomain.AssemblyResolve
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/appdomain.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index 9f5749abaa..ed6d05fc87 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -5328,7 +5328,7 @@ EndTry2:; // Use CoreClr's fusion alternative CoreBindResult bindResult; - pSpec->Bind(this, fThrowOnFileNotFound, &bindResult, FALSE /* fNgenExplicitBind */, FALSE /* fExplicitBindToNativeImage */); + pSpec->Bind(this, FALSE /* fThrowOnFileNotFound */, &bindResult, FALSE /* fNgenExplicitBind */, FALSE /* fExplicitBindToNativeImage */); hrBindResult = bindResult.GetHRBindResult(); if (bindResult.Found()) @@ -5368,8 +5368,6 @@ EndTry2:; } else { - _ASSERTE(fThrowOnFileNotFound == FALSE); - // Don't trigger the resolve event for the CoreLib satellite assembly. A misbehaving resolve event may // return an assembly that does not match, and this can cause recursive resource lookups during error // reporting. The CoreLib satellite assembly is loaded from relative locations based on the culture, see @@ -5382,8 +5380,12 @@ EndTry2:; fForceReThrow = TRUE; // Managed resolve event handler can throw - // Purposly ignore return value - PostBindResolveAssembly(pSpec, &NewSpec, hrBindResult, &pFailedSpec); + BOOL fFailure = PostBindResolveAssembly(pSpec, &NewSpec, hrBindResult, &pFailedSpec); + + if (fFailure && fThrowOnFileNotFound) + { + EEFileLoadException::Throw(pFailedSpec, COR_E_FILENOTFOUND, NULL); + } } } } @@ -6899,20 +6901,27 @@ HRESULT RuntimeInvokeHostAssemblyResolver(INT_PTR pManagedAssemblyLoadContextToB pAssemblyBindingContext = pLoadedPEAssembly->GetHostAssembly(); } -#ifdef FEATURE_COMINTEROP - if (AreSameBinderInstance(pAssemblyBindingContext, GetAppDomain()->GetWinRtBinder())) + if (fResolvedAssembly) { - // It is invalid to return an assembly bound to an incompatible binder - *ppLoadedAssembly = NULL; - SString name; - spec.GetFileOrDisplayName(0, name); - COMPlusThrowHR(COR_E_INVALIDOPERATION, IDS_HOST_ASSEMBLY_RESOLVER_INCOMPATIBLE_BINDING_CONTEXT, name); - } +#ifdef FEATURE_COMINTEROP + if (AreSameBinderInstance(pAssemblyBindingContext, GetAppDomain()->GetWinRtBinder())) + { + // It is invalid to return an assembly bound to an incompatible binder + *ppLoadedAssembly = NULL; + SString name; + spec.GetFileOrDisplayName(0, name); + COMPlusThrowHR(COR_E_INVALIDOPERATION, IDS_HOST_ASSEMBLY_RESOLVER_INCOMPATIBLE_BINDING_CONTEXT, name); + } #endif // FEATURE_COMINTEROP - // Get the ICLRPrivAssembly reference to return back to. - *ppLoadedAssembly = clr::SafeAddRef(pAssemblyBindingContext); - hr = S_OK; + // Get the ICLRPrivAssembly reference to return back to. + *ppLoadedAssembly = clr::SafeAddRef(pAssemblyBindingContext); + hr = S_OK; + } + else + { + hr = COR_E_FILENOTFOUND; + } } GCPROTECT_END(); |