0

我在 Visual Studio 2010 中有一个解决方案,其中包含一个 C++/CLI 程序集。该程序集充当托管/非托管中间人,因此它既调用解决方案中某些 C# 程序集中的函数,又调用从非托管 C++ 代码导出的函数。C++ 代码驻留在同一解决方案内的项目中,但由于历史原因,该项目不是由该解决方案构建的;它由单独的构建脚本编译和链接。

我们的构建脚本在构建后捆绑了所需的文件以生成一个安装程序,该安装程序仅包含二进制文件而没有项目或解决方案文件,这些被正确地视为内部文件。

通常这很好用;但是最近一个特定的构建在安装后无法运行并出现错误:

An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module.

Additional information: A procedure imported by 'CppCliProj.dll' could not be loaded.

编辑:根据 HansPassant 在评论中的帮助,这似乎不再是解决方案文件的问题,就像以前一样。使用 loader snaps 和cdb,我制作了以下内容:

Microsoft (R) Windows Debugger Version 6.2.9200.20512 X86
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: MyApp.exe
Symbol search path is: *** Invalid ***
****************************************************************************
* Symbol loading may be unreliable without a symbol search path.           *
* Use .symfix to have the debugger choose a symbol path.                   *
* After setting your symbol path, use .reload to refresh symbol locations. *
****************************************************************************
Executable search path is: 
ModLoad: 00820000 00834000   MyApp.exe
ModLoad: 774f0000 77670000   ntdll.dll
2004:14fc @ 91201008 - LdrpInitializeProcess - INFO: Beginning execution of MyApp.exe (C:\Program Files (x86)\Path\To\MyApp.exe)
    Current directory: C:\Windows
    Search path: C:\Windows\SYSTEM32

...<snip lots of output>....

*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll - 
eax=00000000 ebx=00000000 ecx=0cff0000 edx=0018dd68 esi=fffffffe edi=00000000
eip=77590fab esp=0070f980 ebp=0070f9ac iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000246
ntdll!LdrVerifyImageMatchesChecksum+0x96c:
77590fab cc              int     3
0:000> .symfix
0:000> sxe clr
0:000> g

...<snip>...

2004:14fc @ 91232426 - LdrGetDllHandleEx - ENTER: DLL name: kernel32 DLL path: NULL
2004:14fc @ 91232426 - LdrGetDllHandleEx - INFO: Locating DLL kernel32.DLL in path C:\Program Files (x86)\Path\To;;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86\winext\arcade;C:\Program Files (x86)\Business Objects\Common\3.5\bin\NOTES\;C:\Program Files (x86)\Business Objects\Common\3.5\bin\NOTES\DATA\;C:\Training\Git\cmd;C:\Training\Ruby1.9.3\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsP
2004:14fc @ 91232426 - LdrpFindLoadedDll - ENTER: DLL name: kernel32.DLL DLL path: C:\Program Files (x86)\Path\To;;C:\Windows\system32;C:\Windows\system;C:\Windows;.;C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86\winext\arcade;C:\Program Files (x86)\Business Objects\Common\3.5\bin\NOTES\;C:\Program Files (x86)\Business Objects\Common\3.5\bin\NOTES\DATA\;C:\Training\Git\cmd;C:\Training\Ruby1.9.3\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsP
2004:14fc @ 91232426 - LdrpFindLoadedDll - RETURN: Status: 0x00000000
2004:14fc @ 91232426 - LdrGetDllHandleEx - RETURN: Status: 0x00000000
2004:14fc @ 91232426 - LdrGetProcedureAddressEx - INFO: Locating procedure "GetUserPreferredUILanguages" by name
(2004.14fc): CLR exception - code e0434352 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=0070e098 ebx=00000005 ecx=00000005 edx=00000000 esi=0070e144 edi=0095e9f0
eip=76acc41f esp=0070e098 ebp=0070e0e8 iopl=0         nv up ei pl nz ac po nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000212
KERNELBASE!RaiseException+0x58:
76acc41f c9              leave
0:000> !loadby sos clr
0:000> !PrintException
Exception object: 0298c1a0
Exception type:   System.IO.FileLoadException
Message:          A procedure imported by 'CppCliProj.dll' could not be loaded.
InnerException:   <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 8007007f
0:000> !CLRStack
OS Thread Id: 0x14fc (0)
Child SP IP       Call Site
0070f24c 76acc41f [PrestubMethodFrame: 0070f24c] Radan.Radraft.Program.Main(System.String[])
0070f488 76acc41f [GCFrame: 0070f488] 
0:000> k
ChildEBP RetAddr  
0070e0e8 6dc7ba10 KERNELBASE!RaiseException+0x58
0070e178 6dd24c13 clr!RaiseTheExceptionInternalOnly+0x276
0070e1b4 6dedd349 clr!UnwindAndContinueRethrowHelperAfterCatch+0x60
0070e20c 6f6c7ea2 clr!CEEInfo::getCallInfo+0x162
0070e234 6f6c858b clrjit!Compiler::eeGetCallInfo+0x39
0070e92c 6f6c615e clrjit!Compiler::impImportBlockCode+0x2ffa
0070e9b4 6f6c2b03 clrjit!Compiler::impImportBlock+0x21b
0070e9cc 6f6c2b4d clrjit!Compiler::impImport+0xe8
0070e9d8 6f6c2b7e clrjit!Compiler::fgImport+0x22
0070e9e8 6f6c3232 clrjit!Compiler::compCompile+0x37
0070ea24 6f6c3326 clrjit!Compiler::compCompileHelper+0x2df
0070ea94 6f6c3459 clrjit!Compiler::compCompile+0x1ac
0070eb70 6f6c5ddb clrjit!jitNativeCode+0x14e
0070eb94 6dc5fe41 clrjit!CILJit::compileMethod+0x27
0070ebfc 6dc5fecd clr!invokeCompileMethodHelper+0x65
0070ec44 6dc5ff13 clr!invokeCompileMethod+0x31
0070ecac 6dc5fce8 clr!CallCompileMethodWithSEHWrapper+0x2e
0070f068 6dda6e5e clr!UnsafeJitFunction+0x3f9
0070f148 6dda7008 clr!MethodDesc::MakeJitWorker+0x284
0070f1b8 6dc4b100 clr!MethodDesc::DoPrestub+0x45d
0070f21c 00a80842 clr!PreStubWorker+0x12c
WARNING: Frame IP not in any known module. Following frames may be wrong.
0070f234 6dc121bb 0xa80842
0070f264 6dc4a7aa clr!CallDescrWorker+0x33
0070f2e0 6dc4a94c clr!CallDescrWorkerWithHandler+0x8e
0070f420 6dc4a981 clr!MethodDesc::CallDescr+0x194
0070f43c 6dc4a9a1 clr!MethodDesc::CallTargetWorker+0x21
0070f454 6dd99e02 clr!MethodDescCallSite::Call+0x1c
0070f5b8 6dd99f10 clr!ClassLoader::RunMain+0x24c
0070f820 6dd99d24 clr!Assembly::ExecuteMainMethod+0xc1
0070fd04 6dd9a119 clr!SystemDomain::ExecuteMainMethod+0x4ec
0070fd58 6dd9a01a clr!ExecuteEXE+0x58
0070fda4 6dd4cb38 clr!_CorExeMainInternal+0x19f
0070fddc 6e2855ab clr!_CorExeMain+0x4e
0070fde8 735e7f16 mscoreei!_CorExeMain+0x38
0070fdf8 735e4de3 MSCOREE!ShellShim__CorExeMain+0x99
0070fe00 769633aa MSCOREE!_CorExeMain_Exported+0x8
0070fe0c 77529ef2 KERNEL32!BaseThreadInitThunk+0xe
0070fe4c 77529ec5 ntdll!RtlInitializeExceptionChain+0x63
0070fe64 00000000 ntdll!RtlInitializeExceptionChain+0x36

我在 Windows 7 Professional 64 位上运行 32 位应用程序。

4

0 回答 0