IF_FAIL_GO(BindByName(pApplicationContext,
pAssemblyName,
- BIND_CACHE_FAILURES,
+ false, // skipFailureCaching
+ false, // skipVersionCompatibilityCheck
excludeAppPaths,
&bindResult));
}
/* static */
HRESULT AssemblyBinder::BindByName(ApplicationContext *pApplicationContext,
AssemblyName *pAssemblyName,
- DWORD dwBindFlags,
+ bool skipFailureCaching,
+ bool skipVersionCompatibilityCheck,
bool excludeAppPaths,
BindResult *pBindResult)
{
hr = pApplicationContext->GetFailureCache()->Lookup(assemblyDisplayName);
if (FAILED(hr))
{
- if ((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) && RerunBind(dwBindFlags))
+ if ((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) && skipFailureCaching)
{
// Ignore pre-existing transient bind error (re-bind will succeed)
pApplicationContext->GetFailureCache()->Remove(assemblyDisplayName);
IF_FAIL_GO(BindLocked(pApplicationContext,
pAssemblyName,
- dwBindFlags,
+ skipVersionCompatibilityCheck,
excludeAppPaths,
pBindResult));
}
Exit:
- if (FAILED(hr) && CacheBindFailures(dwBindFlags))
+ if (FAILED(hr))
{
- if (RerunBind(dwBindFlags))
+ if (skipFailureCaching)
{
if (hr != HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
{
{
IF_FAIL_GO(BindLocked(pApplicationContext,
pAssemblyName,
- 0 /* Do not IgnoreDynamicBinds */,
+ false, // skipVersionCompatibilityCheck
excludeAppPaths,
&lockedBindResult));
if (lockedBindResult.HaveResult())
}
hr = S_OK;
- pAssembly->SetIsDynamicBind(TRUE);
pBindResult->SetResult(pAssembly);
Exit:
/* static */
HRESULT AssemblyBinder::BindLocked(ApplicationContext *pApplicationContext,
AssemblyName *pAssemblyName,
- DWORD dwBindFlags,
+ bool skipVersionCompatibilityCheck,
bool excludeAppPaths,
BindResult *pBindResult)
{
HRESULT hr = S_OK;
BINDER_LOG_ENTER(W("AssemblyBinder::BindLocked"));
- BOOL fIgnoreDynamicBinds = IgnoreDynamicBinds(dwBindFlags);
-
#ifndef CROSSGEN_COMPILE
ContextEntry *pContextEntry = NULL;
IF_FAIL_GO(FindInExecutionContext(pApplicationContext, pAssemblyName, &pContextEntry));
if (pContextEntry != NULL)
{
- if (fIgnoreDynamicBinds && pContextEntry->GetIsDynamicBind())
- {
- // Dynamic binds need to be always considered a failure for binding closures
- IF_FAIL_GO(FUSION_E_APP_DOMAIN_LOCKED);
- }
#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
- else if (IgnoreRefDefMatch(dwBindFlags))
+ if (skipVersionCompatibilityCheck)
{
// Skip RefDef matching if we have been asked to.
}
HRESULT hr = S_OK;
BINDER_LOG_ENTER(W("AssemblyBinder::Register"));
- if (!pBindResult->GetIsContextBound())
- {
- pApplicationContext->IncrementVersion();
+ _ASSERTE(!pBindResult->GetIsContextBound());
- // Register the bindResult in the ExecutionContext only if we dont have it already.
- // This method is invoked under a lock (by its caller), so we are thread safe.
- ContextEntry *pContextEntry = NULL;
- hr = FindInExecutionContext(pApplicationContext, pBindResult->GetAssemblyName(), &pContextEntry);
- if (hr == S_OK)
- {
- if (pContextEntry == NULL)
- {
- ExecutionContext *pExecutionContext = pApplicationContext->GetExecutionContext();
- IF_FAIL_GO(pExecutionContext->Register(pBindResult));
- }
- else
- {
- // The dynamic binds are compiled in CoreCLR, but they are not supported. They are only reachable by internal API Assembly.Load(byte[]) that nobody should be calling.
- // This code path does not handle dynamic binds correctly (and is not expected to). We do not expect to come here for dynamic binds.
+ pApplicationContext->IncrementVersion();
- _ASSERTE(!pContextEntry->GetIsDynamicBind());
-
- // Update the BindResult with the contents of the ContextEntry we found
- pBindResult->SetResult(pContextEntry);
- }
+ // Register the bindResult in the ExecutionContext only if we dont have it already.
+ // This method is invoked under a lock (by its caller), so we are thread safe.
+ ContextEntry *pContextEntry = NULL;
+ hr = FindInExecutionContext(pApplicationContext, pBindResult->GetAssemblyName(), &pContextEntry);
+ if (hr == S_OK)
+ {
+ if (pContextEntry == NULL)
+ {
+ ExecutionContext *pExecutionContext = pApplicationContext->GetExecutionContext();
+ IF_FAIL_GO(pExecutionContext->Register(pBindResult));
+ }
+ else
+ {
+ // Update the BindResult with the contents of the ContextEntry we found
+ pBindResult->SetResult(pContextEntry);
}
}
CRITSEC_Holder contextLock(pApplicationContext->GetCriticalSectionCookie());
// Attempt uncached bind and register stream if possible
+ // We skip version compatibility check - so assemblies with same simple name will be reported
+ // as a successfull bind. Below we compare MVIDs in that case instead (which is a more precise equality check).
hr = BindByName(pApplicationContext,
- pAssemblyName,
- BIND_CACHE_FAILURES|BIND_CACHE_RERUN_BIND|BIND_IGNORE_REFDEF_MATCH,
- false, // excludeAppPaths
- &bindResult);
+ pAssemblyName,
+ true, // skipFailureCaching
+ true, // skipVersionCompatibilityCheck
+ false, // excludeAppPaths
+ &bindResult);
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
{
pPEImage,
NULL,
&bindResult));
-
}
else if (hr == S_OK)
{
IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
}
- // Ensure we are not being asked to bind to a TPA assembly
- //
// Easy out for mscorlib
if (pAssemblyName->IsMscorlib())
{
}
{
+ // Ensure we are not being asked to bind to a TPA assembly
+ //
SString& simpleName = pAssemblyName->GetSimpleName();
- SimpleNameToFileNameMap * tpaMap = GetAppContext()->GetTpaList();
+ SimpleNameToFileNameMap* tpaMap = GetAppContext()->GetTpaList();
if (tpaMap->LookupPtr(simpleName.GetUnicode()) != NULL)
{
// The simple name of the assembly being requested to be bound was found in the TPA list.
if (pCoreCLRFoundAssembly->GetIsInGAC())
{
*ppAssembly = pCoreCLRFoundAssembly.Extract();
- goto Exit;
+ goto Exit;
}
}
}
+ }
- hr = AssemblyBinder::BindUsingPEImage(&m_appContext, pAssemblyName, pPEImage, PeKind, pIMetaDataAssemblyImport, &pCoreCLRFoundAssembly);
- if (hr == S_OK)
- {
- _ASSERTE(pCoreCLRFoundAssembly != NULL);
- pCoreCLRFoundAssembly->SetBinder(this);
- *ppAssembly = pCoreCLRFoundAssembly.Extract();
- }
+ hr = AssemblyBinder::BindUsingPEImage(&m_appContext, pAssemblyName, pPEImage, PeKind, pIMetaDataAssemblyImport, &pCoreCLRFoundAssembly);
+ if (hr == S_OK)
+ {
+ _ASSERTE(pCoreCLRFoundAssembly != NULL);
+ pCoreCLRFoundAssembly->SetBinder(this);
+ *ppAssembly = pCoreCLRFoundAssembly.Extract();
}
Exit:;
}
inline AssemblyName *GetAssemblyName(BOOL fAddRef = FALSE);
inline BOOL GetIsInGAC();
- inline BOOL GetIsDynamicBind();
- inline void SetIsDynamicBind(BOOL fIsDynamicBind);
inline BOOL GetIsByteArray();
inline void SetIsByteArray(BOOL fIsByteArray);
inline BOOL GetIsSharable();
static PEKIND GetSystemArchitecture();
static BOOL IsValidArchitecture(PEKIND kArchitecture);
- inline ICLRPrivBinder* GetBinder()
- {
- return m_pBinder;
- }
+ inline ICLRPrivBinder* GetBinder()
+ {
+ return m_pBinder;
+ }
#ifndef CROSSGEN_COMPILE
protected:
{
FLAG_NONE = 0x00,
FLAG_IS_IN_GAC = 0x02,
- FLAG_IS_DYNAMIC_BIND = 0x04,
+ //FLAG_IS_DYNAMIC_BIND = 0x04,
FLAG_IS_BYTE_ARRAY = 0x08,
FLAG_IS_SHARABLE = 0x10
};
}
}
-BOOL Assembly::GetIsDynamicBind()
-{
- return ((m_dwAssemblyFlags & FLAG_IS_DYNAMIC_BIND) != 0);
-}
-
-void Assembly::SetIsDynamicBind(BOOL fIsDynamicBind)
-{
- if (fIsDynamicBind)
- {
- m_dwAssemblyFlags |= FLAG_IS_DYNAMIC_BIND;
- }
- else
- {
- m_dwAssemblyFlags &= ~FLAG_IS_DYNAMIC_BIND;
- }
-}
-
BOOL Assembly::GetIsByteArray()
{
return ((m_dwAssemblyFlags & FLAG_IS_BYTE_ARRAY) != 0);
static HRESULT TranslatePEToArchitectureType(DWORD *pdwPAFlags, PEKIND *PeKind);
- protected:
- enum
- {
- BIND_NONE = 0x00,
- BIND_CACHE_FAILURES = 0x01,
- BIND_CACHE_RERUN_BIND = 0x02,
- BIND_IGNORE_DYNAMIC_BINDS = 0x04
-#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
- ,
- BIND_IGNORE_REFDEF_MATCH = 0x8
-#endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
- };
-
- static BOOL IgnoreDynamicBinds(DWORD dwBindFlags)
- {
- return ((dwBindFlags & BIND_IGNORE_DYNAMIC_BINDS) != 0);
- }
-
- static BOOL CacheBindFailures(DWORD dwBindFlags)
- {
- return ((dwBindFlags & BIND_CACHE_FAILURES) != 0);
- }
-
- static BOOL RerunBind(DWORD dwBindFlags)
- {
- return ((dwBindFlags & BIND_CACHE_RERUN_BIND) != 0);
- }
-
-#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
- static BOOL IgnoreRefDefMatch(DWORD dwBindFlags)
- {
- return ((dwBindFlags & BIND_IGNORE_REFDEF_MATCH) != 0);
- }
-#endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
-
+ private:
static HRESULT BindByName(/* in */ ApplicationContext *pApplicationContext,
/* in */ AssemblyName *pAssemblyName,
- /* in */ DWORD dwBindFlags,
+ /* in */ bool skipFailureCaching,
+ /* in */ bool skipVersionCompatibilityCheck,
/* in */ bool excludeAppPaths,
/* out */ BindResult *pBindResult);
static HRESULT BindLocked(/* in */ ApplicationContext *pApplicationContext,
/* in */ AssemblyName *pAssemblyName,
- /* in */ DWORD dwBindFlags,
+ /* in */ bool skipVersionCompatibilityCheck,
/* in */ bool excludeAppPaths,
/* out */ BindResult *pBindResult);
inline IUnknown *GetAssembly(BOOL fAddRef = FALSE);
inline Assembly *GetAsAssembly(BOOL fAddRef = FALSE);
- inline BOOL GetIsDynamicBind();
- inline void SetIsDynamicBind(BOOL fIsDynamicBind);
inline BOOL GetIsInGAC();
inline void SetIsInGAC(BOOL fIsInGAC);
inline BOOL GetIsContextBound();
return static_cast<Assembly *>(GetAssembly(fAddRef));
}
-BOOL BindResult::GetIsDynamicBind()
-{
- return ((m_dwResultFlags & ContextEntry::RESULT_FLAG_IS_DYNAMIC_BIND) != 0);
-}
-
-void BindResult::SetIsDynamicBind(BOOL fIsDynamicBind)
-{
- if (fIsDynamicBind)
- {
- m_dwResultFlags |= ContextEntry::RESULT_FLAG_IS_DYNAMIC_BIND;
- }
- else
- {
- m_dwResultFlags &= ~ContextEntry::RESULT_FLAG_IS_DYNAMIC_BIND;
- }
-}
-
BOOL BindResult::GetIsInGAC()
{
return ((m_dwResultFlags & ContextEntry::RESULT_FLAG_IS_IN_GAC) != 0);
{
_ASSERTE(pContextEntry != NULL);
- SetIsDynamicBind(pContextEntry->GetIsDynamicBind());
SetIsInGAC(pContextEntry->GetIsInGAC());
SetIsContextBound(fIsContextBound);
SetIsSharable(pContextEntry->GetIsSharable());
{
_ASSERTE(pAssembly != NULL);
- SetIsDynamicBind(pAssembly->GetIsDynamicBind());
SetIsInGAC(pAssembly->GetIsInGAC());
SetIsSharable(pAssembly->GetIsSharable());
SAFE_RELEASE(m_pAssemblyName);
typedef enum
{
RESULT_FLAG_NONE = 0x00,
- RESULT_FLAG_IS_DYNAMIC_BIND = 0x01,
+ //RESULT_FLAG_IS_DYNAMIC_BIND = 0x01,
RESULT_FLAG_IS_IN_GAC = 0x02,
//RESULT_FLAG_FROM_MANIFEST = 0x04,
RESULT_FLAG_CONTEXT_BOUND = 0x08,
SAFE_RELEASE(m_pIUnknownAssembly);
}
- BOOL GetIsDynamicBind()
- {
- return ((m_dwResultFlags & RESULT_FLAG_IS_DYNAMIC_BIND) != 0);
- }
-
- void SetIsDynamicBind(BOOL fIsDynamicBind)
- {
- if (fIsDynamicBind)
- {
- m_dwResultFlags |= RESULT_FLAG_IS_DYNAMIC_BIND;
- }
- else
- {
- m_dwResultFlags &= ~RESULT_FLAG_IS_DYNAMIC_BIND;
- }
- }
-
BOOL GetIsInGAC()
{
return ((m_dwResultFlags & RESULT_FLAG_IS_IN_GAC) != 0);
SAFE_NEW(pContextEntry, ContextEntry);
- pContextEntry->SetIsDynamicBind(pBindResult->GetIsDynamicBind());
pContextEntry->SetIsInGAC(pBindResult->GetIsInGAC());
pContextEntry->SetIsSharable(pBindResult->GetIsSharable());
pContextEntry->SetAssemblyName(pBindResult->GetAssemblyName(), TRUE /* fAddRef */);
COMPlusThrowHR(COR_E_INVALIDOPERATION, IDS_HOST_ASSEMBLY_RESOLVER_DYNAMICALLY_EMITTED_ASSEMBLIES_UNSUPPORTED, name);
}
- // Is the assembly already bound using a binding context that will be incompatible?
- // An example is attempting to consume an assembly bound to WinRT binder.
pResolvedAssembly = pLoadedPEAssembly->GetHostAssembly();
}
_ASSERTE(pResolvedAssembly != NULL);
#ifdef FEATURE_COMINTEROP
+ // Is the assembly already bound using a binding context that will be incompatible?
+ // An example is attempting to consume an assembly bound to WinRT binder.
if (AreSameBinderInstance(pResolvedAssembly, GetAppDomain()->GetWinRtBinder()))
{
// It is invalid to return an assembly bound to an incompatible binder