2008-09-18 80 views
1

我想在Visual Studio 2008下編譯一個依賴於msvcr90.dll作爲私有程序集的DLL(基本上我會將這個DLL轉儲到與我的應用程序相同的目錄中),而無需外部清單文件。如何編譯不需要外部清單文件的DLL?

我跟着http://msdn.microsoft.com/en-us/library/ms235291.aspx「部署的Visual C++庫的DLL爲專用程序集」但 而不是使用外部清單文件(即 Microsoft.VC90.CRT.manifest)我想介紹的步驟以某種方式將其嵌入到DLL中。

如果我將Microsoft.VC90.CRT.manifest嵌入msvcr90.dll或DLL加載它,並刪除外部清單文件,LoadLibrary()失敗。

問題是,當你嵌入清單成一個DLL,它實際上嵌入如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
manifestVersion="1.0"> 
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 
    <security> 
     <requestedPrivileges> 
     <requestedExecutionLevel level="asInvoker" uiAccess="false"> 
     </requestedPrivileges> 
    </security> 
    </trustInfo> 
    <dependency> 
    <dependentAssembly> 
     <assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"> 
    </dependentAssembly> 
    </dependency> 
</assembly>

我覺得< dependentAssembly>行是什麼導致它,如果 清單文件丟失死亡。有任何想法嗎?

回答

1

以下添加到預處理器定義:

_CRT_NOFORCE_MANIFEST