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
835
Save/Load of Grid layout results in NullRef Exception
posted

Hi,

I have some code that saves and loads a grid layout exactly as described by Mike in the post here (http://ko.infragistics.com/community/forums/p/26520/97683.aspx#97683). On upgrade from 9.1 to 12.1, we're seeing some issues when someone is trying to load a layout that they had saved back during 9.1 (I can't create a sample for repro yet unfortunately). The error that we're seeing is

   at Infragistics.Win.UltraWinGrid.UltraGridLayout.LoadHelper(Stream stream, PropertyCategories propertyCategories, IFormatter formatter)

   at Infragistics.Win.UltraWinGrid.UltraGridLayout.LoadFromXml(Stream stream, PropertyCategories propertyCategories)

   at Infragistics.Win.UltraWinGrid.UltraGridLayout.LoadFromXml(Stream stream)

I've seen a few posts mentioning this stack, but it usually had something to do with old references that weren't updated (not an issue for us) or some misuse of encoding into the stream. The encoding is something we don't do, although I must confess I did notice we were previously using ascii encoding but only on load of the layout, not save...just to be clear, this is what we were doing before:

On save:

MemoryStream memStream = new MemoryStream();
mGrid.DisplayLayout.SaveAsXml(memStream);
if (memStream != null)
{
memStream.Position = 0;
StreamReader reader = new StreamReader(memStream);

<do something with the xml data here>

}

On load:

{

MemoryStream memStream = new MemoryStream(ASCIIEncoding.ASCII.GetBytes(pLayoutXML));
mGrid.DisplayLayout.LoadFromXml(memStream);

}

Having seen the above-linked post, I changed the loading code to match what Mike recommended, but alas that didn't seem to help (and given that the original 9.1 layout was saved without an encoder, I think that is proof that encoding isn't the issue)

On taking a look at the source code for UltraGridLayout, I'm seeing the contents of LoadHelper, but it isn't clear to me what exactly is null...but it is probably the result of formatter.Deserialize( stream ) which means that there is probably something wrong with the stream, right?

Any help would be appreciated. Thanks!

Parents Reply Children
No Data