运行时尝试查找exe/dll,而不是.winmd引用



我有一个使用引用库的应用程序。该库又引用了.winmd库。

查看参考库的IL,我可以看到这个参考:

.assembly extern windowsruntime FlurryWin8SDK
{
  .ver 0:9:0:0
}

然而,在运行时,我遇到了一个异常:

{"Could not load file or assembly 'FlurryWin8SDK' or one of its dependencies. The system cannot find the file specified.":"FlurryWin8SDK"}

此外,通过使用Procmon,我发现有人试图搜索FlurryWin8SDK.exe和FlurryWin8SDK.dll,但没有搜索扩展名为.winmd的文件。

此外,这是Fusion日志查看器的输出:

BEGIN : Framework bind.
END   : The provided identity format is not recognized. (Exception from HRESULT: 0x80132003)
BEGIN : Windows Runtime Type bind.
END   : The provided identity format is not recognized. (Exception from HRESULT: 0x80132003)
BEGIN : Immersive bind.
END   : The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

这种奇怪行为的原因是什么?

这不是奇怪的行为。WinRT为DLL地狱设置了一个硬停止,这种问题你不能指望商店用户来解决。一个非常严格的要求是所有依赖项都包含在应用程序包中。Windows将只在该程序包中查找DLL。

这使得使用.winmd文件变得不那么有用。你只会在一个大型产品中考虑它,它是由许多单独的解决方案构建的,这些解决方案都是单独包装的。

托管WinRT类型有时可以在winmd文件中嵌入代码。但是,如果.net程序集包含任何不是WinRT类型的公共类型,则它们将位于扩展名为.Dll的.net程序集中。您的组件可能在DLL和winmd文件中都包含代码。

最新更新