BestOwl / MyPhone

Connect your mobile devices (Android/iOS/WindowsPhone) to PC
MIT License
191 stars 37 forks source link

Could not open the UWP App: System.IO.FileLoadException #8

Closed MeZdd closed 2 years ago

MeZdd commented 2 years ago

I compile successfully according to the description in Readme.md, but an exception is thrown after clicking open app after running

“MyPhone.exe”(CoreCLR: DefaultDomain): 已加载“C:\Program Files\WindowsApps\Microsoft.NET.CoreRuntime.2.2_2.2.29713.2_x64__8wekyb3d8bbwe\System.Private.CoreLib.dll”。
“MyPhone.exe”(CoreCLR: CoreCLR_UWP_Domain): 已加载“D:\VSWrokspace\MyPhone\PackageProject\bin\x64\Debug\AppX\entrypoint\MyPhone.exe”。已加载符号。
“MyPhone.exe”(CoreCLR: CoreCLR_UWP_Domain): 已加载“D:\VSWrokspace\MyPhone\PackageProject\bin\x64\Debug\AppX\System.Runtime.dll”。
“MyPhone.exe”(CoreCLR: CoreCLR_UWP_Domain): 已加载“D:\VSWrokspace\MyPhone\PackageProject\bin\x64\Debug\AppX\WinMetadata\Windows.winmd”。模块已生成,不包含符号。
“MyPhone.exe”(CoreCLR: CoreCLR_UWP_Domain): 已加载“C:\Program Files\WindowsApps\Microsoft.NET.CoreFramework.Debug.2.2_2.2.29301.2_x64__8wekyb3d8bbwe\mscorlib.dll”。
“MyPhone.exe”(CoreCLR: CoreCLR_UWP_Domain): 已加载“D:\VSWrokspace\MyPhone\PackageProject\bin\x64\Debug\AppX\System.Runtime.InteropServices.WindowsRuntime.dll”。
“MyPhone.exe”(CoreCLR: CoreCLR_UWP_Domain): 已加载“C:\Program Files\WindowsApps\Microsoft.NET.CoreFramework.Debug.2.2_2.2.29301.2_x64__8wekyb3d8bbwe\System.Runtime.WindowsRuntime.dll”。
引发的异常:“System.IO.FileLoadException”(位于 MyPhone.exe 中)
“System.IO.FileLoadException”类型的异常在 MyPhone.exe 中发生,但未在用户代码中进行处理
Could not load file or assembly 'System.Runtime.InteropServices.WindowsRuntime, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I am a novice developer of win. After Google search, I found that there may be a version conflict. The version specified in the package reference is inconsistent with the local installation, but I don't know how to locate and solve the problem. I hope to get your guidance. Thank you! I found that you are a Chinese, if it is convenient, I can trouble you to communicate in Chinese. Hope to receive your reply!

MeZdd commented 2 years ago

This is my computer environment

Win10 19043.1288
VS2019 16.11.4
BestOwl commented 2 years ago

我在升级到最新版的Visual Studio 2019后 (16.11.4)也遇到了这个问题。目前看来可能是因为项目里有两个 UWP project,而更新后的 MSIX Packaging Project 不支持两个 UWP project 同时存在。

BestOwl commented 2 years ago

解决方案是把MyPhone.TrayApp 的 XamlHost 改成 MyPhone (Universal Windows) 然后把 MyPhone.TrayApp.XamlHost 删掉。 不过我可能要到下个星期之后才有时间解决这个问题。

临时的解决方法是降级Visual Studio。

MeZdd commented 2 years ago

好的,非常感谢您的回复。由于我刚刚接触Win端开发不久,只大致熟悉了相关语言和IDE,所以暂时对您提供的解决方案无从下手,我对您项目的实现原理很感兴趣,正在艰难研读您的代码。

BestOwl commented 2 years ago

我在升级到最新版的Visual Studio 2019后 (16.11.4)也遇到了这个问题。目前看来可能是因为项目里有两个 UWP project,而更新后的 MSIX Packaging Project 不支持两个 UWP project 同时存在。

刚才尝试了把 MyPhone.TrayAppMyPhone.TrayApp.XamlHost 从解决方案和 PackagedProject 里删除,发现还是有问题。所以可能不是因为有两个UWP的问题。

BestOwl commented 2 years ago

Just tested on Visual Studio 2022 (v17.0.0 Preview 4.1), the UWP app launch successfully.

MeZdd commented 2 years ago

您好,请问现在的办法只能是升级VS或者降级VS吗

BestOwl commented 2 years ago

您好,请问现在的办法只能是升级VS或者降级VS吗

是的。

MeZdd commented 2 years ago

请问您编译成功的2019版本是多少呢,我这边好降级到该版本。感谢

BestOwl commented 2 years ago

请问您编译成功的2019版本是多少呢,我这边好降级到该版本。感谢

我记得我升级之前是 v16.9.x

BestOwl commented 2 years ago

This issue will be solved after #9

BestOwl commented 2 years ago

Close because #12 solved this issue.