简体   繁体   English

Visual Studio MSIX 应用创建:入口点 (.exe) 不正确

[英]Visual Studio MSIX App Creation: Entry Point (.exe) not correct

I have made a Windows Forms Project which hosts a WPF User Control (some kind of 3D Viewport), which are basically two "seperate" Projects. I have made a Windows Forms Project which hosts a WPF User Control (some kind of 3D Viewport), which are basically two "seperate" Projects. Combining these two in one Main Project did work and i can access the Wpf with my Windows Forms App.将这两者结合在一个主项目中确实有效,我可以使用我的 Windows Forms 应用程序访问 Wpf。 In the next step i wanted to create an "MSIX" App as Visual Studio 2019 suggests.在下一步中,我想按照 Visual Studio 2019 的建议创建一个“MSIX”应用程序。 So i inserted a "third" Project Template ( the MSIX project template ) and set up the References like in the official how to Guide.所以我插入了一个“第三个”项目模板(MSIX 项目模板),并像官方指南一样设置参考。 So that was mainly linking my "Main" Windows Forms Program as an Application in the MSIX Template and also setting it as an "Entry Point" for the App.所以这主要是将我的“主要”Windows Forms 程序链接为 MSIX 模板中的应用程序,并将其设置为应用程序的“入口点”。

My WPF Program is referenced in my Main Program so i didnt have to link this in the MSIX Template again.我的主程序中引用了我的 WPF 程序,因此我不必再次在 MSIX 模板中链接它。 So far so good.到目前为止,一切都很好。 The Debugging also doesnt bring any Errors.调试也不会带来任何错误。 But instead of opening the Main program (which is WinForms) as defined Entry Point, the Debugger opens just the WPF Application ( which is actually only accessible through a ButtonClick Event in the Windows Forms Programm)....但是,调试器不会打开定义的入口点的主程序(即 WinForms),而是仅打开 WPF 应用程序(实际上只能通过 Windows Z6450242531912981C3683CAE6 中的 ButtonClick 事件访问)...

In the.wapproj file:在 .wapproj 文件中:

<EntryPointProjectUniqueName>..\..\Visu 2.0 Core\Visu 2.0 Core\Visu 2.0 Core.csproj</EntryPointProjectUniqueName>

which is the Folderplace of my imported project (Main WindowsForms program part) which i do want to run..这是我想要运行的导入项目(主 WindowsForms 程序部分)的文件夹。

I read about the property我阅读了有关该物业的信息

<EntryPointexe/>

I now have two places where i could get my.exes from: the folder where i originally created the program or the folder where i "built" the project anew together with the MSIX project specific stuff ( under a new project name) So i dont really get if setting this could help out.我现在有两个地方可以从中获取 my.exes:我最初创建程序的文件夹或我重新“构建”项目的文件夹以及 MSIX 项目特定的东西(在新项目名称下)所以我不真的得到如果设置这个可以帮助。 It seems more to be an other reason why my App wont run/show the initial (windows)form.这似乎是我的应用程序无法运行/显示初始(Windows)表单的另一个原因。

My attempts to setting the also somehow had an effect on the AppxManifest.xml file located in我尝试设置也以某种方式对位于的 AppxManifest.xml 文件产生影响

..\source\repos\AppTest2\AppTest2\bin\AnyCPU\Debug\AppxManifest.xml

Has anybody an advice why my App Project (even though the entry point) doesnt want to know anything from my 1. Program Part?有没有人建议为什么我的应用程序项目(即使是入口点)不想从我的 1. 程序部分中了解任何内容? ( it is just not run but the second program WPF though) (它只是没有运行,但第二个程序 WPF 虽然)

@ Knally.Based on my test, I use Windows Forms Project as Entry Point in MSIX Template, it opens Windows Forms Project and WPF User Control is loaded when the button is clicked. @ Knally.Based on my test, I use Windows Forms Project as Entry Point in MSIX Template, it opens Windows Forms Project and WPF User Control is loaded when the button is clicked. You can check if the steps are consistent with yours.您可以检查步骤是否与您的一致。 And if there is any problem, please let me know.如果有任何问题,请告诉我。

Here are my code in.wapproj file:这是我在.wapproj 文件中的代码:

<EntryPointProjectUniqueName>..\WindowsFormsApp1\WindowsFormsApp1.csproj</EntryPointProjectUniqueName>

The steps:步骤:

  1. Create WPF App Project named WpfApp1 and build to WpfApp1.dll.创建名为 WpfApp1 的 WPF 应用程序项目并构建到 WpfApp1.dll。

1.Create a new WPF App Project 1.新建WPF App项目

2.Add a User Control 2.添加用户控件

3.Create control 3.创建控件

4.Delete Window1 and App files in Solution Explorer 4.在解决方案资源管理器中删除Window1和App文件

5.Project > WpfApp1 Properties > Application > Output Type = Class Library 5.项目 > WpfApp1 属性 > 应用程序 > Output 类型 = Class 库

6.Build solution... .dll file is in the bin/Release folder 】 6.构建解决方案... .dll文件在bin/Release文件夹】

2.Create Windows Forms App named WindowsFormsApp1 and add reference MyControl.dll. 2.创建名为WindowsFormsApp1的Windows Forms App并添加引用MyControl.dll。

【Right click References in WindowsFormsApp1->select Add Reference… ->select Browse ->find and Add WpfApp1.dll->click OK】 【在WindowsFormsApp1中右键References->选择Add Reference... ->选择Browse ->find and Add WpfApp1.dll->点击OK】

The Form1.cs code: Form1.cs 代码:

using System;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using WpfApp1;
namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ElementHost host = new ElementHost();
            host.Dock = DockStyle.Bottom;
            UserControl1 myControl = new UserControl1();
            host.Child = myControl;
            this.Controls.Add(host);
        }
    }
}

3.Create Windows Application Packaging Project named WapProjTemplate1. 3.创建名为WapProjTemplate1的Windows应用程序打包项目。

1.Right click Applications -> click Add Reference… ->Select WindowsFormsApp1 ->click OK 1.右键应用程序->点击添加引用...- >选择WindowsFormsApp1- >点击确定

2.Double click Package.appxmanifest ->Click Packaging ->click Choose Certificate… ->click Create…->enter password->OK 2.双击Package.appxmanifest- >点击打包->点击选择证书...- >点击创建...->输入密码->确定

3.modify your Configuration Manager as below: 3.修改您的配置管理器,如下所示: 在此处输入图像描述

在此处输入图像描述

4.Right click WapProjTemplate1 ->select Publish ->select Create App Packages… ->select Release for Architecture on Select and configure packages wizard as below: 4.右键WapProjTemplate1 -> 选择Publish -> 选择Create App Packages... -> 选择 Release for Architecture on Select 并配置包向导如下:

在此处输入图像描述

The result:结果: 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM