I have recently upgrade my solution from Infragistics 7.3 to 9.2 (9.2.20092.1003).
I use the following code to save the grid layout to a database table:
MemoryStream XMLStore = new MemoryStream();
System.Text.
UTF8Encoding enc = new System.Text.UTF8Encoding();
this.dgQueryResult.DisplayLayout.SaveAsXml(XMLStore);
string strLayout = enc.GetString(XMLStore.GetBuffer());
And this code to read the string and apply it to the grid.
strLayout = dsTmp.Tables[
"QUERY_FILTER"].Rows[0]["QUERY_LAYOUT"].ToString();
if (strLayout.Length > 0)
{
XMLStore.Write(enc.GetBytes(strLayout), 0, strLayout.Length);
XMLStore.Position = 0;
this.dgQueryResult.DisplayLayout.LoadFromXml(XMLStore);
}
This worked fine in previous versions and will work now if I save the layout using v9.2.
However, if I attempt to load a layout in 9.2 that was saved with the code at 7.3, I get the following exception on the LoadFromXml line:
"Object reference not set to an instance of an object." at Infragistics.Win.UltraWinGrid.UltraGridLayout.LoadHelper(Stream stream, PropertyCategories propertyCategories, IFormatter formatter)\r\n at Infragistics.Win.UltraWinGrid.UltraGridLayout.LoadFromXml(Stream stream, PropertyCategories propertyCategories)\r\n at Infragistics.Win.UltraWinGrid.UltraGridLayout.LoadFromXml(Stream stream)\r\n
I've looked at the two strings and see a very large number of differences so it's difficult for me to determine what the issue might be.
I have attached a file containing the text from the layout for v7.3.
Can anyone suggest what I should look at to determine the cause of this problem?
Thanks,
Gerry
Hi Gerry,
I layout can only be loaded into a grid that has the same data structure as the grid for which the layout was saved. So I can't really test your layout in the same way you are using it.
I tried loading the layout file into an UltraGridLayout variable like so:
UltraGridLayout layout = new UltraGridLayout();layout.LoadFromXml(@"C:\Users\MikeS\Desktop\Layout73.txt");
Can you duplicate this in a small sample project in v7.2 so that we can save the layout, upgrade the project, and then load the layout into v9.2 and get the exception?
I'm not completely sure that I understand your request.
However, I wrote some test code in my project to load the layout from the file into a new UltraGridLayout variable instead of directly into the grid, essentially copying the snippet that you attached.
I get the same exception as I originally listed. Are you saying that your test loaded the layout without error?