I have the following code:
try {
using (var stream = new MemoryStream()) {
var ms = stream;
if (control is DockLayoutManager) {
if (control.Dispatcher == null || control.Dispatcher.CheckAccess()) {
((DockLayoutManager)control).SaveLayoutToStream(ms);
}
}
}
} catch (Exception e) {
log.Error(string.Format("Cannot GetLayout ({0}).", typeName), e);
}
From time to time, I get a NullReferenceException on the line
((DockLayoutManager)control).SaveLayoutToStream(ms);
I have no idea, why there can be a NullReferenceException on this line.
I hope, someone can help me.