If I use a Application.LoadComponent()UserControl, page or window to load, my application freezes when I try to close it.
The application closes, but the process continues to work. Easy to spot when debugging.
I tested it under Windows 7 64bit and Vista 32bit. In both cases, I used VS2008 and .NET 3.5.
Reproduction can be created by creating the wpf application as follows:
public partial class Window1 : Window {
public Window1() {
InitializeComponent();
}
public void LoadCopy() {
var uri = new Uri("/WpfApplication1;component/window1.xaml", UriKind.Relative);
var copy = (Window)Application.LoadComponent(uri);
MessageBox.Show(copy.Title);
}
private void Button_Click(object sender, EventArgs e) {
LoadCopy();
}
}
Does anyone know what could happen? And how to solve it?
source
share