R
Robert P.
I can easily store a one-dimensional array in viewstate ( see Test1 )
If I try storing a multi-dimensional array in the viewstate it's crapping
out on me when it goes to [de]serialize the array (not when I make the
assignment).
Interestingly, I get a very different error depending on the type of array
( string or decimal ).
I'm not doing anything fancy, just a regular old aspx page with a single
button and the following code ( commented/uncomment as desired):
// TEST #1 -- This works
string[] test1 = new string[1];
test1[0] = "0";
ViewState["_test1"] = test1;
// TEST #2 -- Causes Error
// ERROR: Array was not a one-dimensional array.
// TRACE: System.Array.GetValue(Int32 index) +80
decimal[,] test2 = new decimal[1,2];
test2[0,0] = (decimal)1.0;
test2[0,1] = (decimal)2.2;
ViewState["_test2"] = test2;
// TEST #3 -- Causes Error
// ERROR: Specified cast is not valid.
// TRACE: System.Web.UI.LosFormatter.SerializeValue(TextWriter output,
Object value) +1117
string[,] test3 = new string[1,2];
test3[0,0] = "00";
test3[0,1] = "01";
ViewState["_test3"] = test3;
If I try storing a multi-dimensional array in the viewstate it's crapping
out on me when it goes to [de]serialize the array (not when I make the
assignment).
Interestingly, I get a very different error depending on the type of array
( string or decimal ).
I'm not doing anything fancy, just a regular old aspx page with a single
button and the following code ( commented/uncomment as desired):
// TEST #1 -- This works
string[] test1 = new string[1];
test1[0] = "0";
ViewState["_test1"] = test1;
// TEST #2 -- Causes Error
// ERROR: Array was not a one-dimensional array.
// TRACE: System.Array.GetValue(Int32 index) +80
decimal[,] test2 = new decimal[1,2];
test2[0,0] = (decimal)1.0;
test2[0,1] = (decimal)2.2;
ViewState["_test2"] = test2;
// TEST #3 -- Causes Error
// ERROR: Specified cast is not valid.
// TRACE: System.Web.UI.LosFormatter.SerializeValue(TextWriter output,
Object value) +1117
string[,] test3 = new string[1,2];
test3[0,0] = "00";
test3[0,1] = "01";
ViewState["_test3"] = test3;