在 Visual Studio 中为 MSIX 打包设置桌面应用程序时出错 [英] Error when setting up desktop application for MSIX packing in Visual Studio

查看:32
本文介绍了在 Visual Studio 中为 MSIX 打包设置桌面应用程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了

备注:我的WPF项目,MyWPFProject是一个.NET 5项目,Application Packaging Project项目名称是WapProjTemplate1.我正在使用 VS2019

的最新版本 16.9.3

问题:为什么会出现错误,以及我们如何解决它.如下图所示,我的两个项目都针对同一个平台.

<块引用><块引用>

错误:正在构建的项目MSIL"与处理器架构之间存在不匹配.以及参考C:\MyFolder\MyWPFProject\bin\x86\Debug\net5.0-windows\win-x86\MyWPFProject.dll"、x86"的处理器架构.这种不匹配可能会导致运行时失败.请考虑通过配置管理器更改项目的目标处理器架构,以便在您的项目和参考之间对齐处理器架构,或者依赖于具有匹配项目目标处理器架构的处理器架构的参考.WapProjTemplate1 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets

解决方案

请尝试如下修改您的配置管理器:

完成上述步骤后,请右键单击您的WapProjTemplate1,在弹出窗口中选择发布并选择创建应用程序包...然后选择选择和配置包向导中为架构发布,如下所示:

更新:

在 86 位 Windows 操作系统上:使用 Any CPU 编译的可执行文件和 DLL 在 32 位 CLR 上执行.在 64 位 Windows 操作系统上:使用 Any CPU 编译的 DLL 在与加载它的进程相同的 CLR 上执行.使用 Any CPU 编译的可执行文件在 64 位 CLR 上执行.程序的目标平台和引用的 DLL 在运行时应该是一致的.一般来说,我们可以根据实际需要设置程序的Target Platform与部署的操作系统一致,DLL最好是Any CPU.特殊的部署环境需要特殊的考虑.可能是因为你的项目兼容Any CPU"但是您依赖于 x86 或 x64 的项目或 DLL.由于您有 x86 依赖项,因此从技术上讲,您的项目与任何 CPU"不兼容.

I followed this tutorial from official Microsoft team to use the Windows Application Packaging Project project in Visual Studio to generate a package for my WPF desktop app. A Note here reads: If you're packaging a desktop application, right click on the the Windows Application Packaging Project node.. So I did just that (as shown below). But at the end of the wizard, I got the error shown at the end below:

Remark: My WPF project, MyWPFProject is a .NET 5 project, and the Application Packaging Project project name is WapProjTemplate1. I'm using latest version 16.9.3 of VS2019

Question: Why the error, and how can we resolve it. As, the following figure shows, my both projects target the same platform.

Error: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\MyFolder\MyWPFProject\bin\x86\Debug\net5.0-windows\win-x86\MyWPFProject.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. WapProjTemplate1 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets

解决方案

Please try to modify your Configuration Manager as below:

After completing the above steps, please right click your WapProjTemplate1, choose Publish on the popup and select Create App Packages... Then select Release for Architecture on Select and configure packages wizard as below:

Update:

On a 86-bit Windows operating system: Executables and DLL that are compiled with the Any CPU execute on the 32-bit CLR. On a 64-bit Windows operating system: A DLL compiled with the Any CPU executes on the same CLR as the process into which it's loaded. Executables that are compiled with the Any CPU execute on the 64-bit CLR. The Target Platform of the program and the referenced DLL should be consistent at runtime. Generally speaking, we can set the Target Platform of the program to be consistent with the deployed operating system according to actual needs and the DLL is preferably Any CPU. The special deployment environment requires special consideration. Maybe because your project is compatible with "Any CPU" but you have a dependency on a project or DLL that is either x86 or x64. Because you have an x86 dependency, technically your project is therefore not compatible with "Any CPU".

这篇关于在 Visual Studio 中为 MSIX 打包设置桌面应用程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆