Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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>


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.


Edit: 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).

Posted
Updated 27-Sep-11 21:43pm
v6

1 solution

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.
 
Share this answer
 
Comments
[no name] 23-Sep-11 16:49pm    
Sorry for that. Both are not actually in the XAML I copied from Visual Studio. The xmlns:x="#unknown"> appears to be added as soon as I paste the code into the editor here. And the property 'Background' always is changed to 'removed' :) I have already tried to correct it, but only with little success.

Edit: I can try to edit both as often as I want, they are always back when I post my changed question.
Edit again: Finally got it!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900