Dll loading order

2019-06-07 21:49发布

If i have global variable in A.dll, that depends on global variable in B.dll , is it guaranteed that B.dll will be loaded before A.dll? I made two sample dll projects in Visual Studio, and link A.dll with B.dll , and it seems, that B.dll is loaded first.So is this behavior guaranteed ?

1条回答
淡お忘
2楼-- · 2019-06-07 22:06

This behavior is guaranteed by the OS, because otherwise it would be impossible to write proper dll-loading code. In particular, if A.dll imports B.dll, then when the dynamic linker attempts to load A.dll, it will see that dependency and load B.dll into the process first.

查看更多
登录 后发表回答