首页 > 解决方案 > C#程序在其他计算机上不起作用

问题描述

我制作了一个连接到服务器并监听某些数据包的应用程序,为此我使用了 Nuget 网络库。这是我的 .csproj 文件:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RootNamespace>remote_client</RootNamespace>
    <Platforms>AnyCPU;x64</Platforms>
    <UseWPF>true</UseWPF>
    <UseWindowsForms>true</UseWindowsForms>
    <StartupObject>remote_client.client</StartupObject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Network" Version="6.1.4.20" />
    <PackageReference Include="System.Management.Automation" Version="7.0.0" />
  </ItemGroup>

  <ItemGroup>

  </ItemGroup>

</Project>

然后我遇到了如何将其编译成单个.exe 文件的问题。我找到了我在 powershell 中使用的命令(我在项目目录中运行它):

dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true

然后我有了一个文件,可以在我电脑的任何地方使用。当我试图将它交给我的朋友时,它无法在 Windows 中出现错误(我的翻译):无法运行此应用程序。要求程序的开发人员做点什么... 我的 Windows 版本是 1909,他的版本是 1809。
总而言之,我需要解决这个问题或找到一些简单的方法来发布应用程序并将其编译成一个 windows-universal 单个 .exe 文件。

编辑:实际的错误信息是:

This application will not work on your computer. To find the version for this computer, contact the software publisher.

第一句是弹出消息框的标题,第二句显示为消息。

标签: c#windows

解决方案


我的错,我认为它无法工作,因为我朋友运行应用程序的计算机是 32 位的,但我将它编译为 64 位。


推荐阅读