我需要可靠地重定向应用程序查找特定的DLL.使用app.exe.local方法不起作用,因为如果应用程序具有清单(嵌入或单独的文件),则会忽略本地文件.所以我试图通过将DLL定义为清单中的私有程序集来进行DLL重定向.
我有一个测试应用程序,LoadDll.exe只是调用
LoadLibrary("C:\\EmptyDll.dll");
Run Code Online (Sandbox Code Playgroud)
LoadDll.exe具有清单(作为单独的文件,LoadDll.exe.manifest)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.1"
processorArchitecture="x86"
name="LoadDll"
type="win32"
/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="EmptyDll"
version="1.0.0.1"
processorArchitecture="x86"
/>
</dependentAssembly>
</dependency>
</assembly>
Run Code Online (Sandbox Code Playgroud)
包含LoadDll.exe(NOT c:\)的Application文件夹包含带有嵌入式清单的EmptyDll.dll.
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<assemblyIdentity
type="win32"
name="EmptyDll"
version="1.0.0.1"
processorArchitecture="x86"
/>
</assembly>
Run Code Online (Sandbox Code Playgroud)
但是,LoadDll.exe继续并加载C:\ EmptyDll.dll,而不是应用程序文件夹中的EmptyDll.dll.
如果您中断任一清单(例如,更改EmptyDll.dll清单标识中的版本号),则不会加载LoadDll.exe,因此清单文件正由Windows读取和处理,但只是被忽略.
有人有任何想法吗?
谢谢!
托比