活动在发行版本中不起作用 [英] Events not working in release build

查看:56
本文介绍了活动在发行版本中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这非常令人困惑,目前我不知道原因可能是什么.我有一个WPF应用程序,可作为Web服务的客户端. Web服务和服务器组件已被完全重写,但是客户端保持不变.

调试版本可以正常工作,在发行版本中,我只会得到一个空的主窗口.我已将问题跟踪到主窗口本身.这里是它的XAML:

This is very confusing and at the moment I have no idea what the cause might be. I have a WPF application which serves as client for a webservice. The webservice and the server components have been completely rewritten, but the client has remained unchanged.

A debug build will work without problems, in a release build I will just get an empty main window. I have tracked the problem down to the main window itself. Here its XAML:

<Window x:Class="FoC.FocAdmonClient.MainWindow.cMainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" ResizeMode="CanResizeWithGrip" Icon="/FocAdmonClient;component/FoC.ico" Loaded="Window_Loaded" Closing="Window_Closing">
    <Grid x:Name="LayoutRoot" Background="{StaticResource ContentBackground}">
    </Grid>
</Window>



运行时,主窗口的构造函数将正常执行.之后,一旦加载主窗口,就会触发"Loaded"事件.这永远不会发生,因此主窗口保持为空.

关闭空窗口时,应触发"Closing"事件.这也永远不会发生.窗口的背景颜色变为黑色,窗口保持打开状态.

同样,在调试版本中一切正常.这两个事件都可以正常运行.


我已经找到了这种奇怪行为的原因:

以前,该项目是在具有32位OS的计算机上开发和构建的.我的新机器有一个64位操作系统.该项目被设置为针对任何CPU"进行编译.将其重新设置为"x86"即可解决该问题,并且现在可以在两种类型的OS以及发行版或调试版中使用.

任何CPU"设置对于让JIT编译器利用64位系统同时仍能够在32位系统上运行而言可能是实用的.但是在这种情况下,这似乎不适用于WPF应用程序,并导致事件不触发(至少在64位系统上).



When running, the constructor for the main window is executed normally. After that the ''Loaded'' event should fire as soon as the main window is loaded. This never happens and so the main window remains empty.

On closing the empty window, the ''Closing'' event should fire. This also never happens. The background color of the window just changes to black and the window remains open.

Again, everything is ok in a debug build. Both events work perfectly then.


I have found the cause of this strange behavior:

Previously the project was being developed and built on a computer with a 32 bit OS. My new machine has a 64 bit OS. The project was set to compile for ''any CPU''. Setting it back to ''x86'' solved the problem and works now on both types of OS as well as in release or debug builds.

The ''any CPU'' setting may be practical to let the JIT compiler take advantage of 64 bit systems while still being able to run on 32 bit systems. But in this case it looks like this does not work for WPF applications and causes the events not to fire (at least on 64 bit systems).

推荐答案

0)查看xaml的第一行.删除xmlns:x="#unknown">

1)网格中的removed属性是什么?我不熟悉.
0) Look at the first line of your xaml. Remove the xmlns:x="#unknown">

1) what is the removed property in the grid? I''m not familiar with that.


这篇关于活动在发行版本中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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