I'm using UltraDockManager to manage docking layouts for my application. It seems that the docking file got corrupted or save incorrectly and the dock manager cannot import the file now.
if (File.Exists(_fractionDockLayout) == true)
Logging.Logger.Warning("Error loading the fractions docking layout: " + ex.Message);
Even with the LoadFromXml call inside a try/catch block with a generic exception handler, the application crashes as soon as the LoadFromXML line is run. Turning on exception breaking in Visual Studio, I can see that the error is "System.ArgumentException: Height must be greater than 0px.'
We are using WinForms, Infragistics 2017.1, targeting .NET 4.0
How can I recover gracefully from this situation so my application can still run without having to go manually delete the layout XML file?
Thank you for contacting Infragistics!
Currently there isn’t a way to recover the layout xml file. Can you attach your sample so it can be looked into why this is failing and throwing the exception?
Mike, thank you for the response. It's okay if I'm unable to recover the saved layout. I just need a way to handle the exception gracefully so my software doesn't crash if the layout is invalid. Is there a way to check the validity of a layout before calling LoadFromXml? I've attached the XML layout - hopefully it is useful for determining where the failure is occurring.
The layout file in this case won't do us much good unless we have an application with the appropriate controls to load.
Just as a test, I tried loading the XML file you provided into a DockManager on a form without the controls, and it loads fine with no errors.
What must be happening here is that the XML is loading correctly. It then applies it's settings to the controls and dock windows in your application. And so the try..catch doesn't catch any errors. But then something it applied causes an error when the form or paints or performs a layout. We could probably confirm this if you post the call stack of the exception you are getting.
So the only way to catch an exception like that would be to set up your application to catch ALL exceptions for the lifetime of the app. I think there are several strategies for this. But I guess one would be to wrap the call to your main form's constructor in a try...catch block. And frankly, that seems like a bad idea.
If you could provide us with a sample application that has all the controls on it so we could run it and track down the error, this is probably something we should fix in the DockManager. It should probably be validating the data when it applies it to the controls, if possible - instead of blowing up on a paint.