我將一個 UWP 應用程序更新為更新的 SDK,并將目標版本設置為 16299,將最小版本設置為 15063。然后我使用 Windows.Foundation.UniversalApiContract 命名空間來使用新 SDK 的功能(如果可用)。示例:xmlns:contract5NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,5)"xmlns:contract5Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,5)"<contract5Present:NavigationView x:Name="NavView" ...構建失敗,未顯示任何錯誤消息。但是當我將構建日志設置為詳細時,它似乎找不到程序集:Could not resolve this reference. Could not locate the assembly "Windows.Foundation.FoundationContract, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.文件夾和文件存在于 C:\Program Files (x86)\Windows Kits\10\References**10.0.16299.0**\Windows.Foundation.FoundationContract\3.0.0.0 AND C:\Program Files (x86)\Windows Kits \10\References**10.0.15063.0**\Windows.Foundation.FoundationContract\3.0.0.0更新 1:這似乎與我的資源詞典和亞克力畫筆有關。如果我將資源字典復制到空白應用程序,則會發生相同的錯誤。如果我從資源字典中刪除合同內容和所有丙烯酸刷子,則構建成功。那么我在這里錯過了什么?如果我從字典中刪除第一行(粗細),則構建成功。我的系統在2018年4 月更新上運行,但我在另一臺安裝了Fall Creators Update 的機器上遇到了同樣的問題。解決方案:我已將 ThemeResources 和 Styles 拆分為兩個單獨的 ResourceDictionaries,現在在我的主項目中構建成功。但我不明白為什么會發生這種情況以及為什么沒有出現確切的錯誤消息。我花了大約 8 個小時(我的項目有 >70000 行代碼)來找到問題,對此我有點生氣:)
1 回答

白板的微信
TA貢獻1883條經驗 獲得超3個贊
您的16299和15063 SDK文件好像有問題,您可以嘗試打開文件資源管理器,到對應的文件位置查看SDK是否存在。
路徑應該是: C:\Program Files (x86)\Windows Kits\10\References\10.0.15063.0(10.0.16299.0)\Windows.Foundation.FoundationContract\3.0.0.0\
否則,您可以嘗試從Windows SDK and emulator archive再次下載并安裝 SDK 版本。
如果仍然無法解決,請嘗試將Microsoft.NETCore.UniversalWindowsPlatform Nuget更新到最新版本,然后重新啟動您的 VS,再次清理并重建您的應用程序。順便說一句,還請提供您的設備操作系統版本和操作系統版本,以幫助我調查此問題。
---更新---
另一種解決方法是您可以在標記對之后聲明 ResourceDictionary 的內容<ResourceDictionary.ThemeDictionaries></ResourceDictionary.ThemeDictionaries>
。這將防止觸發崩潰。
- 1 回答
- 0 關注
- 830 瀏覽
添加回答
舉報
0/150
提交
取消