ClickOnce 发布的 WPF 应用程序启动但无法打开特定窗口
我正在尝试 ClickOnce 发布服务。我只需以仅在线模式将我的解决方案发布到共享文件夹,运行网页即可启动我的应用程序。
我点击一个按钮,打开一个窗口,很好,另一个,也很好,然后第三个,窗口没有显示。
我所知道的是:
这不是丢失的 DLL,没有异常(异常记录器)并且它在发布/调试中工作正常
您是否有任何提示/想法为什么会出现这种情况以及如何寻找问题?
I am trying ClickOnce publishing service. I simply publish my solution to a share folder in online only mode, run the web page and my application starts.
I cick a button that open a window fine, another one, fine too and then a third one and the window don't show up.
What I know:
It's not a missing DLL, there is no exception (exception logger) and it's working fine in Release/Debug
Do you have any hint/idea why this and how to hunt for the problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将该文件添加到项目中,并将构建操作设置为“内容”,将“复制到输出目录”设置为“始终复制”。然后,由于它是 XML 文件,因此请进入“发布”选项卡中的“应用程序文件”对话框,并将文件从“包含(数据)”更改为“包含(必需)”。
如果将其部署为数据,它会将其放入 DataDirectory 中,而不是将其包含在与主程序集相同的文件夹中。 Include(Data) 是 XML 文件的默认设置。 (很烦人,不是吗?)
You can add the file to your project and set the build action to "content" and "copy to output directory" to "copy always". Then, because it's an XML file, go into the Application Files dialog in the Publish tab and change the file from "Include(Data)" to "Include(Required)".
If you deploy it as data, it will put it in the DataDirectory instead of including it in the same folder as the main assemblies. Include(Data) is the default for XML files. (Annoying, isn't it?)
我使用基于文件的跟踪工具。我发现 XML 文件有问题。我在 MSDN 上找到了一篇 博客文章关于那个。我发现构建操作和发布操作不一样。
所以窗口的问题是它需要该 XML 文件但没有找到它。它抛出了一个异常,但异常记录器没有捕获它,因为它位于另一个线程上。 (然后我学会了将异常转发到主线程)。
最后,似乎无法发布来自 DLL 的文件。它必须嵌入到 DLL 中或移动到主 UI 项目(已发布的项目)。
I use a file-based trace tool. I found out that there was a problem with an XML file. I found a blog post on MSDN that talks about that. I appear that the build action and the publish action ain't the same.
So the problem of the window was that it needed that XML file but didn't find it. It threw an exception but the exception logger didn't catch it because it was on another thread. (I then learned to foward exception to the main thread).
Finally, it seems you can't publish a file when it's from a DLL. It must be embedded to the DLL or moved to the main UI project (the published project).