Upgrading a working project from .NET Framework 4.8 to .NET 6.0 and these lines fail to compile.
The XML methods are just not there.
"SaveAsXML is not a member of UltraGridLayout"
What gives?
Me.udsNextActivities.LoadFromXml(objStream)
...
mobjGrid.DisplayLayout.LoadFromXml(objLayoutStream, PropertyCategories.All And Not PropertyCategories.ValueLists)
mobjGrid.DisplayLayout.SaveAsXml(objLayoutStream, PropertyCategories.All And Not PropertyCategories.ValueLists)
Hi Simon,
since I had the same problem as you have, I needed to find a solution for the problem.
Happily I succeeded.
The following code is written in .Net6 using the SoapFormatter Nugget Version 1.1.9
private void convertUltraGridLayoutFromXmlToBinary(string xmlFilename, string binaryFilename) { UltraGridLayout layout; #region load the UltraGrid from XML FileStream fileStream = new FileStream(xmlFilename, FileMode.Open, FileAccess.Read); try { SoapFormatter soapFormatter = new SoapFormatter(null, new StreamingContext(StreamingContextStates.Persistence)) { AssemblyFormat = FormatterAssemblyStyle.Simple, Binder = new Infragistics.Win.UltraWinGrid.Serialization.Binder() }; layout = soapFormatter.Deserialize(fileStream) as UltraGridLayout; } finally { fileStream.Close(); } #endregion #region save the UltraGrid to binary fileStream = new FileStream(binaryFilename, FileMode.OpenOrCreate, FileAccess.Write); try { BinaryFormatter binaryFormatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Persistence)) { AssemblyFormat = FormatterAssemblyStyle.Simple }; if (layout != null) { #pragma warning disable SYSLIB0011 binaryFormatter.Serialize(fileStream, layout); #pragma warning restore SYSLIB0011 } } finally { fileStream.Close(); } #endregion }
Just execute this method before you do DisplayLayout.Load(...), which was LoadFromXML(...) before.
Hope that helps you, too.
Hello Simon,
If you are looking for the Save/LoadFromXML methods to return, I would recommend suggesting a product idea for this functionality at our Ideas Site for Windows Forms. This will place you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.
Regards, Ivan Kitanov
This is a huge problem for us as the SaveAsXML method was used to save to a TextStream which could then be saved in a VARCHAR(Max) column in a table in the database, allowing grid layouts to be saved and shared between users. Do you expect to recode these methods to return them to the product in a future version?
The issue has been discussed in this forum post:
https://es.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/124253/net6-ultragrid-missing-methods-loadfromxml-and-saveasxml/545405#545405
To sum it up, the reason why the LoadFromXML and SaveAsXml methods are not present is that they both are using the SoapFormatter class extensively, which is only supported in .NET Framework. The workaround that has been suggested is to use the Save and Load methods, which generate and load binary file. If you have an XML file that needs to be loaded, it is recommended that you first load it in a .NET Framework application and then re-save it using the Save method.
In the below documentation page there is an example of how the Save/Load methods could be used:
https://es.infragistics.com/help/winforms/infragistics.win.ultrawingrid~infragistics.win.ultrawingrid.ultragridlayout~save(stream,propertycategories)