WPF ClickOnce缺少参考 [英] WPF ClickOnce missed references

查看:126
本文介绍了WPF ClickOnce缺少参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,可与本地SQLite和Entity Framework Core一起使用.我想使用ClickOnce分发我的应用程序.

I have a WPF app that works with local SQLite and Entity Framework Core. I want to distribute my app using ClickOnce.

当我使用Visual Studio 2017运行它时,一切正常.但是,当我使用ClickOnce时,应用程序在启动时崩溃.崩溃太早了,所以我什至无法记录异常.一段时间后,我发现在publish文件夹中缺少一些dll.例如System.Runtime.所有引用均为NuGet软件包.然后,我发现尽管我在我的项目中有对dll的引用,但ClickOnce应用程序文件列表中却没有包含该dll.

Everything works fine when I run it using Visual Studio 2017. But app had a crash on a start when I used ClickOnce. The crash was so early so I couldn't even log the exception. After some time I found that in publish folder some dlls were missed. For example System.Runtime. All references are NuGet packages. Then I found that despite of I have a reference to the dlls in my project ClickOnce application files list doesn't contains it.

我现在发现的唯一解决方案是将丢失的dll作为文件添加到我的项目的根目录中,并将构建操作设置为内容".在ClickOnce应用程序文件对话框中,我将发布状态设置为包括.

The only solution I have found for now is to add missed dlls as files in root of my project and set build action to Content. In ClickOnce application file dialog I set publish status to Include.

它现在可以工作,但是看起来并不是最好的方法.问题是为什么首先错过它们.我很可能错过了一些东西,或者我不了解问题的根源.

It works now but it looks like not the best way to do it. The question is why they are missed in the first place. More likely I missed something or I am not understand the root of the problem.

UPD:

您可以在此处找到示例代码.

You can find an example code here.

它可以在Visual Studio中运行,但是当您尝试将其安装为ClickOnce应用程序时,会在启动时崩溃.

It works from Visual Studio but crashes on a start when you try to install it as ClickOnce application.

UPD:该问题已在Visual Studio Professional 15.6.1版中解决

UPD: The problem was fixed in Visual Studio Professional version 15.6.1

推荐答案

有两种方法可以解决此问题.

首先,您必须进入属性发布应用程序文件,然后在此处使您的DLL文件包括在您的项目中

At first, you have to go PropertiesPublishApplication Files, and at this place, make your DLL files include in your project

但是,如果它不起作用,请转至引用",然后将DLL文件设置为 CopyLocal = False .您在项目中添加一个 Existing Item 之类的DLL文件,并使其始终复制.

But if it does not work, go to References and make the DLL file CopyLocal = False. You add a DLL file like Existing Item in your project and make them Copy Always.

它将正常工作.

但是对于您的样品,我看了看并解决了.看这张图片:

But for your sample I watch this and I solved it. Look at this image:

您有四个DLL文件.您需要为他们这样做:

You have four DLL files. You need do this for them:

System.Diagnostics.Tracing.dll
System.Reflection.dll
System.Runtime.dll
System.Runtime.Extensions.dll

首先请参考,并使其复制本地错误:

然后转到每个DLL文件的路径,并将它们添加为 Existing Item ,然后将它们全部复制到输出目录中并始终

Then go to the path of each DLL file and add them like Existing Item, and then make all of them Copy To Output Directory CopyAlways

然后 Publish 并按如下图所示运行它.我从发布文件运行它,并且可以正常工作.

Then Publish it and run it like in this picture. I run it from publish file and it works.

这篇关于WPF ClickOnce缺少参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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