Including UWP project in WPF project raises runtime errors

梦想与她 提交于 2020-01-16 16:50:13

问题


Project I work on need to show UWP control from UWP library inside of WPF window. Here is the document page on which I had based my work (check section for adding custom UWP control): https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/wpf-winforms/windowsxamlhost#add-a-custom-uwp-control

Had setup WPF window and it shows standard UWP controls (like button) at the runtime just fine. However, when I include UWP project, WPF window throws exception at start (at the moment of context initialization of EF).

Could not load file or assembly 'Windows.Foundation.UniversalApiContract, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

Sqlite version I'm using is 1.0.88.0 and EF is 5. But it doesn't make any sense that it clashes with these libraries?


回答1:


Ffixed an issue on startup by updating SQLite package to 1.0.111.0 and EF to version 6.2.0.




回答2:


Including UWP project in WPF project raises runtime errors

Derive from official document, I create sample project. When build the project, it throw many errors that lost assembly. After add the Windows.winmd file every thing work well. You could try to add the Windows.winmd file where in the C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd to WPF app reference.

Detail steps

Right click project References -> Add References -> Browse(file type all file)-> select Windows.winmd

And this sample project that you could refer this.



来源:https://stackoverflow.com/questions/57313797/including-uwp-project-in-wpf-project-raises-runtime-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!