Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
.NET 6.0 UltraDataSource & UltraGridLayout missing LoadFromXML and SaveAsXML methods
posted

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)

Parents
No Data
Reply
  • 15
    Offline posted

    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.

Children
No Data