2

我有一个使用 Visual Studio 2008 开发的 .NET 应用程序,它使用名为xVJob.dll的 C++/CLI DLL 。

当我尝试在测试 VM 上运行它时出现 SideBySide 错误。VM 正在运行 Windows Server 2003 SP2。

我可以在我的开发机器上运行和调试一切正常,但是当我尝试在测试 VM 上运行它时,它会引发异常:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembl
y 'xVJob, Version=1.0.3883.15147, Culture=neutral, PublicKeyToken=null' or one o
f its dependencies. This application has failed to start because the application
 configuration is incorrect. Reinstalling the application may fix this problem.
(Exception from HRESULT: 0x800736B1)
File name: 'xVJob, Version=1.0.3883.15147, Culture=neutral, PublicKeyToken=null'
 ---> System.Runtime.InteropServices.COMException (0x800736B1): This application
 has failed to start because the application configuration is incorrect. Reinsta
lling the application may fix this problem. (Exception from HRESULT: 0x800736B1)

   at Jobs.JobMonitor.MonitorThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

我已将 Microsoft.VC90.DebugCRT 和 Microsoft.VC90.DebugMFC 文件夹从 C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\Debug_NonRedist 复制到 VM 上包含可执行文件的文件夹中。

构建 xVJob.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>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.DebugMFC' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

Debug_NonRedist 运行时 DLL 的清单表明它们是 version version=" 9.0.30729.4148 "。

以下事件记录到系统事件日志中:

在清单中找到的组件标识与请求的组件标识不匹配

第 4 行的清单或策略文件“...\Microsoft.VC90.DebugCRT\Microsoft.VC90.DebugCRT.MANIFEST”中有语法错误。

这是 Microsoft.VC90.DebugCRT.MANIFEST 文件的内容:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <noInheritable></noInheritable>
    <assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.30729.4148" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    <file name="msvcr90d.dll" hashalg="SHA1" hash="af453f3ee64ff975e704d8241daee695e423e6b8"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>qLOzJNR/6Gg8hHyBY2oMP6cuf4E=</dsig:DigestValue></asmv2:hash></file> <file name="msvcp90d.dll" hashalg="SHA1" hash="7689e9e00acb4d25542085d44724a5759cac93b5"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>ItToY/v0CGa5SMBJskUQJE64qlI=</dsig:DigestValue></asmv2:hash></file> <file name="msvcm90d.dll" hashalg="SHA1" hash="86cfdcb727b087b5bf963d87a14056a10ca46b24"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>QdrglJI4vM+V6T5D6iJv08yi+W0=</dsig:DigestValue></asmv2:hash></file>
</assembly>

我不明白为什么我在使用 xVJob.dll 和运行时文件生成的清单中得到不同的运行时版本。

请帮忙!

4

1 回答 1

1

The answers to this question helped me resolve this problem:

App does not run with VS 2008 SP1 DLLs, previous version works with RTM versions

In particular, defining _BIND_TO_CURRENT_VCLIBS_VERSION in my preprocessor settings for all of my projects seems to have done the trick.

于 2010-08-19T22:54:09.610 回答