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