【问题标题】:0x8007007E only in Windows Phone target0x8007007E 仅在 Windows Phone 目标中
【发布时间】:2017-09-26 11:03:45
【问题描述】:

我的目标是一个带有 UWP C++ 通用 Windows 项目引用的 C# 应用程序,该引用位于相同的解决方案中。此应用程序在 Windows 桌面上正常运行,没有任何错误,但是当我尝试在 Windows Phone 设备上运行它时,我收到以下错误:

System.IO.FileNotFoundException: The specified module could not be found. >(Exception from HRESULT: 0x8007007E)
   at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
   at *CALLED METHOD HERE*
   at Demo.MainPage..ctor()'Demo.exe' (Win32): Loaded

我检查了 csproj 看看它是直接引用 wincmd 文件还是 dll 但它确实引用了另一个项目。

我已尝试检查设备存储,但找不到在设备中探索已部署应用内容的方法。

目标平台版本/min.version:10.0.14393.0

编辑 1:

看起来问题是生成的 DLL 引用了 ucrtbased.dll

File Type: DLL

  Image has the following dependencies:

    api-ms-win-core-com-l1-1-1.dll
    api-ms-win-core-debug-l1-1-1.dll
    api-ms-win-core-synch-l1-2-0.dll
    api-ms-win-core-synch-l1-2-1.dll
    api-ms-win-core-sysinfo-l1-2-1.dll
    vccorlib140d_app.DLL
    MSVCP140D_APP.dll
    ADVAPI32.dll
    VCRUNTIME140D_APP.dll
    ucrtbased.dll
    api-ms-win-core-winrt-string-l1-1-0.dll
    api-ms-win-core-util-l1-1-0.dll
    api-ms-win-core-winrt-error-l1-1-1.dll
    api-ms-win-core-handle-l1-1-0.dll
    api-ms-win-core-errorhandling-l1-1-1.dll
    api-ms-win-core-string-l1-1-0.dll
    api-ms-win-core-processthreads-l1-1-2.dll
    api-ms-win-core-winrt-l1-1-0.dll
    api-ms-win-core-profile-l1-1-0.dll
    api-ms-win-core-libraryloader-l1-2-0.dll
    api-ms-win-core-interlocked-l1-2-0.dll
    api-ms-win-core-heap-l1-2-0.dll
    api-ms-win-core-memory-l1-1-2.dll

编辑 2:

Visual Studio 包含 ucrt/arm 路径作为库路径。我正在使用 Visual Studio 2017

LibraryPath = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\lib\ARM\store;;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\atlmfc\lib\ARM;;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\VS\lib\ARM;;C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\ucrt\arm;;;C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\um\arm;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.2\lib\um\arm;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Lib\um\arm

编辑 3:

由于某种原因,_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 似乎是从某个地方继承的,允许 ARM 目标(所有项目)访问桌面 API。这会导致问题吗?

编辑 4: 使用 dumpbin /imports 我可以获取我的程序正在使用的 ucrtbased.dll 函数列表,其中大多数是 stdlib 函数:

ucrtbased.dll
          10D0E7E4 Import Address Table
          10D0F430 Import Name Table
                 0 time date stamp
                 0 Index of first forwarder reference

              527 strcpy_s
              523 strcat_s
               69 __stdio_common_vsprintf_s
              3B2 _wsplitpath_s
              55F wcscpy_s
              396 _wmakepath_s
              174 _initterm_e
              33C _wassert
              175 _invalid_parameter
                5 _CrtDbgReportW
              562 wcslen
              52C strlen
              47F free
              4DC mbstowcs_s
              526 strcpy
              53A strtol
               CD _difftime64
              296 _mktime64
               6A __stdio_common_vsscanf
              575 wcstombs
              500 realloc
              3C2 _wtoi
              54F toupper
               36 __acrt_iob_func
              173 _initterm
              4FE rand
              410 ceil
              44A exit
              166 _gmtime64_s
              318 _time64
              4D3 malloc
               E0 _errno
              3D0 abort
              52F strncmp
              12C _ftime64
              55C wcscmp
              11D _free_dbg
              203 _malloc_dbg
                4 _CrtDbgReport
               A2 _callnewh
              2BD _seh_filter_dll
               B7 _configure_narrow_argv
              170 _initialize_narrow_environment
              171 _initialize_onexit_table
              2B1 _register_onexit_function
               E6 _execute_onexit_table
               C3 _crt_atexit
               C2 _crt_at_quick_exit
               A5 _cexit
               5D __stdio_common_vfprintf

目前的怀疑:使用 ADVAPI32.dll 依赖。

【问题讨论】:

  • 所以你是说这可能是一个未解决的无法解释的答案的重复?那里有两个人评论了两个不同的问题,作者选择了他的回复作为答案,但是它没有解释如何解决这个声称是微软对应的错误的问题。我在目标设备 10.0.14393.0 中使用了最新版本。如果这是一个错误,您能否解释一下如何避免它以及如何确保我的应用程序不包含 ucrt 引用?

标签: c# c++ uwp windows-10-universal


【解决方案1】:

所以这是我堆栈中的罪魁祸首:ADVAPI32.dll。

我使用的是加载 SystemFunction036 (RtlGenRandom) 的依赖项,解决方案是重新编写代码以使用具有相同功能的等效 UWP 函数。

微软真的应该重新考虑他们向开发人员报告此类问题的方式,因为该异常似乎与问题完全无关。一个简单的异常表明 ADVAPI32.dll 是加载 UWP 移动版本中不允许的函数的罪魁祸首。由于这是一个运行时问题,因此您的代码可以正常编译,而您永远不知道您的代码将无法工作,除非您对其进行测试。

【讨论】:

    猜你喜欢
    • 2016-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多