Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
8e93e728
R
runtime
项目概览
dotNET Platform
/
runtime
大约 1 年 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8e93e728
编写于
11月 20, 2019
作者:
E
Elinor Fung
提交者:
GitHub
11月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Slight refactor in looking at app paths in AssemblyBinder::BindByTpaList (#115)
上级
4593d2b0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
139 addition
and
147 deletion
+139
-147
src/coreclr/src/binder/assemblybinder.cpp
src/coreclr/src/binder/assemblybinder.cpp
+139
-147
未找到文件。
src/coreclr/src/binder/assemblybinder.cpp
浏览文件 @
8e93e728
...
...
@@ -711,55 +711,120 @@ namespace BINDER_SPACE
return
pBoundAssemblyName
->
Equals
(
pRequestedAssemblyName
,
dwIncludeFlags
);
}
HRESULT
BindSatelliteResourceByResourceRoots
(
ApplicationContext
*
pApplicationContext
,
StringArrayList
*
pResourceRoots
,
AssemblyName
*
pRequestedAssemblyName
,
BindResult
*
pBindResult
)
namespace
{
HRESULT
hr
=
S_OK
;
HRESULT
BindSatelliteResourceByProbingPaths
(
const
StringArrayList
*
pResourceRoots
,
AssemblyName
*
pRequestedAssemblyName
,
BindResult
*
pBindResult
)
{
HRESULT
hr
=
S_OK
;
SString
&
simpleNameRef
=
pRequestedAssemblyName
->
GetSimpleName
();
SString
&
cultureRef
=
pRequestedAssemblyName
->
GetCulture
();
SString
&
simpleNameRef
=
pRequestedAssemblyName
->
GetSimpleName
();
SString
&
cultureRef
=
pRequestedAssemblyName
->
GetCulture
();
_ASSERTE
(
!
cultureRef
.
IsEmpty
()
&&
!
cultureRef
.
EqualsCaseInsensitive
(
g_BinderVariables
->
cultureNeutral
));
_ASSERTE
(
!
cultureRef
.
IsEmpty
()
&&
!
cultureRef
.
EqualsCaseInsensitive
(
g_BinderVariables
->
cultureNeutral
));
for
(
UINT
i
=
0
;
i
<
pResourceRoots
->
GetCount
();
i
++
)
{
ReleaseHolder
<
Assembly
>
pAssembly
;
SString
&
wszBindingPath
=
(
*
pResourceRoots
)[
i
];
SString
fileName
(
wszBindingPath
);
for
(
UINT
i
=
0
;
i
<
pResourceRoots
->
GetCount
();
i
++
)
{
ReleaseHolder
<
Assembly
>
pAssembly
;
SString
&
wszBindingPath
=
(
*
pResourceRoots
)[
i
];
SString
fileName
(
wszBindingPath
);
CombinePath
(
fileName
,
cultureRef
,
fileName
);
CombinePath
(
fileName
,
simpleNameRef
,
fileName
);
fileName
.
Append
(
W
(
".dll"
));
CombinePath
(
fileName
,
cultureRef
,
fileName
);
CombinePath
(
fileName
,
simpleNameRef
,
fileName
);
fileName
.
Append
(
W
(
".dll"
));
hr
=
AssemblyBinder
::
GetAssembly
(
fileName
,
FALSE
/* fIsInGAC */
,
FALSE
/* fExplicitBindToNativeImage */
,
&
pAssembly
);
hr
=
AssemblyBinder
::
GetAssembly
(
fileName
,
FALSE
/* fIsInGAC */
,
FALSE
/* fExplicitBindToNativeImage */
,
&
pAssembly
);
// Missing files are okay and expected when probing
if
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
))
{
continue
;
}
// Missing files are okay and expected when probing
if
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
))
{
continue
;
IF_FAIL_GO
(
hr
);
AssemblyName
*
pBoundAssemblyName
=
pAssembly
->
GetAssemblyName
();
if
(
TestCandidateRefMatchesDef
(
pRequestedAssemblyName
,
pBoundAssemblyName
,
false
/*tpaListAssembly*/
))
{
pBindResult
->
SetResult
(
pAssembly
);
GO_WITH_HRESULT
(
S_OK
);
}
IF_FAIL_GO
(
FUSION_E_REF_DEF_MISMATCH
);
}
IF_FAIL_GO
(
hr
);
// Up-stack expects S_OK when we don't find any candidate assemblies and no fatal error occurred (ie, no S_FALSE)
hr
=
S_OK
;
Exit:
return
hr
;
}
HRESULT
BindAssemblyByProbingPaths
(
const
StringArrayList
*
pBindingPaths
,
AssemblyName
*
pRequestedAssemblyName
,
bool
useNativeImages
,
Assembly
**
ppAssembly
)
{
SString
&
simpleName
=
pRequestedAssemblyName
->
GetSimpleName
();
AssemblyName
*
pBoundAssemblyName
=
pAssembly
->
GetAssemblyName
();
if
(
TestCandidateRefMatchesDef
(
pRequestedAssemblyName
,
pBoundAssemblyName
,
false
/*tpaListAssembly*/
)
)
// Loop through the binding paths looking for a matching assembly
for
(
DWORD
i
=
0
;
i
<
pBindingPaths
->
GetCount
();
i
++
)
{
pBindResult
->
SetResult
(
pAssembly
);
GO_WITH_HRESULT
(
S_OK
);
HRESULT
hr
;
ReleaseHolder
<
Assembly
>
pAssembly
;
LPCWSTR
wszBindingPath
=
(
*
pBindingPaths
)[
i
];
PathString
fileNameWithoutExtension
(
wszBindingPath
);
CombinePath
(
fileNameWithoutExtension
,
simpleName
,
fileNameWithoutExtension
);
// Look for a matching dll first
PathString
fileName
(
fileNameWithoutExtension
);
fileName
.
Append
(
useNativeImages
?
W
(
".ni.dll"
)
:
W
(
".dll"
));
hr
=
AssemblyBinder
::
GetAssembly
(
fileName
,
FALSE
,
// fIsInGAC
useNativeImages
,
// fExplicitBindToNativeImage
&
pAssembly
);
if
(
FAILED
(
hr
))
{
fileName
.
Set
(
fileNameWithoutExtension
);
fileName
.
Append
(
useNativeImages
?
W
(
".ni.exe"
)
:
W
(
".exe"
));
hr
=
AssemblyBinder
::
GetAssembly
(
fileName
,
FALSE
,
// fIsInGAC
useNativeImages
,
// fExplicitBindToNativeImage
&
pAssembly
);
}
// Since we're probing, file not founds are ok and we should just try another
// probing path
if
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
))
{
continue
;
}
if
(
FAILED
(
hr
))
return
hr
;
// We found a candidate.
//
// Below this point, we either establish that the ref-def matches, or
// we fail the bind.
// Compare requested AssemblyName with that from the candidate assembly
if
(
!
TestCandidateRefMatchesDef
(
pRequestedAssemblyName
,
pAssembly
->
GetAssemblyName
(),
false
/*tpaListAssembly*/
))
return
FUSION_E_REF_DEF_MISMATCH
;
*
ppAssembly
=
pAssembly
.
Extract
();
return
S_OK
;
}
IF_FAIL_GO
(
FUSION_E_REF_DEF_MISMATCH
);
return
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
);
}
// Up-stack expects S_OK when we don't find any candidate assemblies and no fatal error occurred (ie, no S_FALSE)
hr
=
S_OK
;
Exit:
return
hr
;
}
/*
...
...
@@ -794,10 +859,9 @@ namespace BINDER_SPACE
// followed by App Paths.
//
hr
=
BindSatelliteResourceByResourceRoots
(
pApplicationContext
,
pApplicationContext
->
GetPlatformResourceRoots
(),
pRequestedAssemblyName
,
pBindResult
);
hr
=
BindSatelliteResourceByProbingPaths
(
pApplicationContext
->
GetPlatformResourceRoots
(),
pRequestedAssemblyName
,
pBindResult
);
// We found a platform resource file with matching file name, but whose ref-def didn't match. Fall
// back to application resource lookup to handle case where a user creates resources with the same
...
...
@@ -809,10 +873,9 @@ namespace BINDER_SPACE
if
(
!
pBindResult
->
HaveResult
())
{
IF_FAIL_GO
(
BindSatelliteResourceByResourceRoots
(
pApplicationContext
,
pApplicationContext
->
GetAppPaths
(),
pRequestedAssemblyName
,
pBindResult
));
IF_FAIL_GO
(
BindSatelliteResourceByProbingPaths
(
pApplicationContext
->
GetAppPaths
(),
pRequestedAssemblyName
,
pBindResult
));
}
}
else
...
...
@@ -869,120 +932,49 @@ namespace BINDER_SPACE
if
(
!
excludeAppPaths
)
{
// This loop executes twice max. First time through we probe AppNiPaths, the second time we probe AppPaths
bool
parseAppNiPaths
=
true
;
for
(;;)
// Probe AppNiPaths first, then AppPaths
ReleaseHolder
<
Assembly
>
pAssembly
;
hr
=
BindAssemblyByProbingPaths
(
pApplicationContext
->
GetAppNiPaths
(),
pRequestedAssemblyName
,
true
,
// useNativeImages
&
pAssembly
);
if
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
))
{
StringArrayList
*
pBindingPaths
=
parseAppNiPaths
?
pApplicationContext
->
GetAppNiPaths
()
:
pApplicationContext
->
GetAppPaths
();
// Loop through the binding paths looking for a matching assembly
for
(
DWORD
i
=
0
;
i
<
pBindingPaths
->
GetCount
();
i
++
)
{
ReleaseHolder
<
Assembly
>
pAssembly
;
LPCWSTR
wszBindingPath
=
(
*
pBindingPaths
)[
i
];
SString
&
simpleName
=
pRequestedAssemblyName
->
GetSimpleName
();
// Look for a matching dll first
hr
=
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
);
{
SString
fileName
(
wszBindingPath
);
CombinePath
(
fileName
,
simpleName
,
fileName
);
if
(
parseAppNiPaths
)
{
fileName
.
Append
(
W
(
".ni.dll"
));
hr
=
GetAssembly
(
fileName
,
FALSE
,
// fIsInGAC
TRUE
,
// fExplicitBindToNativeImage
&
pAssembly
);
}
else
{
fileName
.
Append
(
W
(
".dll"
));
hr
=
GetAssembly
(
fileName
,
FALSE
,
// fIsInGAC
FALSE
,
// fExplicitBindToNativeImage
&
pAssembly
);
}
}
if
(
FAILED
(
hr
))
{
SString
fileName
(
wszBindingPath
);
CombinePath
(
fileName
,
simpleName
,
fileName
);
hr
=
BindAssemblyByProbingPaths
(
pApplicationContext
->
GetAppPaths
(),
pRequestedAssemblyName
,
false
,
// useNativeImages
&
pAssembly
);
}
if
(
parseAppNiPaths
)
{
fileName
.
Append
(
W
(
".ni.exe"
));
hr
=
GetAssembly
(
fileName
,
FALSE
,
// fIsInGAC
TRUE
,
// fExplicitBindToNativeImage
&
pAssembly
);
}
else
{
fileName
.
Append
(
W
(
".exe"
));
hr
=
GetAssembly
(
fileName
,
FALSE
,
// fIsInGAC
FALSE
,
// fExplicitBindToNativeImage
&
pAssembly
);
}
}
if
(
hr
!=
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
))
{
IF_FAIL_GO
(
hr
);
// Since we're probing, file not founds are ok and we should just try another
// probing path
if
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
))
// At this point, we have found an assembly with the expected name in the App paths. If this was also found on TPA,
// make sure that the app assembly has the same fullname (excluding version) as the TPA version. If it does, then
// we should bind to the TPA assembly. If it does not, then bind to the app assembly since it has a different fullname than the
// TPA assembly.
if
(
fPartialMatchOnTpa
)
{
if
(
TestCandidateRefMatchesDef
(
pAssembly
->
GetAssemblyName
(),
pTPAAssembly
->
GetAssemblyName
(),
true
/*tpaListAssembly*/
))
{
continue
;
// Fullname (SimpleName+Culture+PKT) matched for TPA and app assembly - so bind to TPA instance.
pBindResult
->
SetResult
(
pTPAAssembly
);
GO_WITH_HRESULT
(
S_OK
);
}
IF_FAIL_GO
(
hr
);
// We found a candidate.
//
// Below this point, we either establish that the ref-def matches, or
// we fail the bind.
// Compare requested AssemblyName with that from the candidate assembly
if
(
TestCandidateRefMatchesDef
(
pRequestedAssemblyName
,
pAssembly
->
GetAssemblyName
(),
false
/*tpaListAssembly*/
))
else
{
// At this point, we have found an assembly with the expected name in the App paths. If this was also found on TPA,
// make sure that the app assembly has the same fullname (excluding version) as the TPA version. If it does, then
// we should bind to the TPA assembly. If it does not, then bind to the app assembly since it has a different fullname than the
// TPA assembly.
if
(
fPartialMatchOnTpa
)
{
if
(
TestCandidateRefMatchesDef
(
pAssembly
->
GetAssemblyName
(),
pTPAAssembly
->
GetAssemblyName
(),
true
/*tpaListAssembly*/
))
{
// Fullname (SimpleName+Culture+PKT) matched for TPA and app assembly - so bind to TPA instance.
pBindResult
->
SetResult
(
pTPAAssembly
);
GO_WITH_HRESULT
(
S_OK
);
}
else
{
// Fullname (SimpleName+Culture+PKT) did not match for TPA and app assembly - so bind to app instance.
pBindResult
->
SetResult
(
pAssembly
);
GO_WITH_HRESULT
(
S_OK
);
}
}
else
{
// We didn't see this assembly on TPA - so simply bind to the app instance.
pBindResult
->
SetResult
(
pAssembly
);
GO_WITH_HRESULT
(
S_OK
);
}
// Fullname (SimpleName+Culture+PKT) did not match for TPA and app assembly - so bind to app instance.
pBindResult
->
SetResult
(
pAssembly
);
GO_WITH_HRESULT
(
S_OK
);
}
IF_FAIL_GO
(
FUSION_E_REF_DEF_MISMATCH
);
}
if
(
!
parseAppNiPaths
)
else
{
break
;
// We didn't see this assembly on TPA - so simply bind to the app instance.
pBindResult
->
SetResult
(
pAssembly
);
GO_WITH_HRESULT
(
S_OK
);
}
parseAppNiPaths
=
false
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录