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
Issue solved.
You're sample lead me directly to the problem in my code. The upgrade process to v9.2 apparently changed the references in all of my projects in the solution except one. When I changed that one from referencing 7.3, everything started working.
Thank you for your quick response and help on this one.
gregehr said:Are you saying that your test loaded the layout without error?
Yes, that is precisely what I am saying. I ran this code loading your layout file into a layout variable and it worked fine for me with no Exception.
It's possible that my machine has a slightly newer version of the grid on it. So on the off chance that there is some fix in place that hasn't been released, yet, I went back and tested this again using the 9.2.20092.1003 build and I still get no exception. So it seems like the exception may be something specific to your machine.
I am attaching my sample here, just so you can run it and make sure we are both doing exactly the same thing.
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?
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 found the 2017 service release for v9.2 and installed it and still get the same error.