question

DimitrievitsGergely-2346 avatar image
0 Votes"
DimitrievitsGergely-2346 asked RoyLi-MSFT commented

[UWP] Bug report: DataTable with extended properties deserialization crashes in release mode

When I call this method in an UWP main page in debug (x86) mode everything is works fine the extended properties shown in the message dialog. But when I called in release (x86) mode the ReadXml() method crashes.

The target platform version: 10.0.19041.0 (latest)
with Visual Studio 2019 (16.11.3).

         private async void Test()
         {
             try
             {
                 using (DataTable dt = new DataTable("Data"))
                 {
                     DataColumn cmn =
                         new DataColumn(
                             "cmn1",
                             typeof(int));
    
                     cmn.ExtendedProperties.Add("Key1", 5);
                     cmn.ExtendedProperties.Add("Key2", "valami");
    
                     dt.Columns.Add(cmn);
    
                     // Serialize
                     string dataTableSer;
                     using (MemoryStream ms = new MemoryStream())
                     {
                         dt.WriteXml(ms, XmlWriteMode.WriteSchema);
                         ms.Position = 0;
                         using (StreamReader sr = new StreamReader(ms))
                         {
                             dataTableSer = sr.ReadToEnd();
                         }
                     }
    
                     //Deserialize
                     string str = string.Empty;
                     using (StringReader stream = new StringReader(dataTableSer))
                     {
                         using (DataSet ds = new DataSet())
                         {
                             ds.ReadXml(stream);
                             DataTable deSerDt = ds.Tables[0];
    
                             foreach (DataColumn deSerCmn in deSerDt.Columns)
                                 foreach (DictionaryEntry extendedProperty in deSerCmn.ExtendedProperties)
                                     str += extendedProperty.Key + " :" + extendedProperty.Value + Environment.NewLine;
    
                         }
                     }
    
                     MessageDialog mb = new MessageDialog(str);
                     await mb.ShowAsync();
                 }
             }
             catch (Exception ex)
             {
                 MessageDialog mb = new MessageDialog(ex.Message);
                 await mb.ShowAsync();
             }
         }
    
         public MainPage()
         {
             this.InitializeComponent();
    
             this.Test();
         }
     }


dotnet-csharpwindows-uwpwindows-uwp-runtime
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


How do you know that it crashes?

0 Votes 0 ·

Run the application in release mode with the code? The exception handler caught the exception and the message dialog shows it.

0 Votes 0 ·

I made a simple test with the code you provided. But the code works correctly on my side in a blank project targeting 19041. You could see in the screenshot, the message dialog shows the value correctly. Could you please tell me what's the exception that you are getting? Have you tried your code in a blank project as well?

0 Votes 0 ·
image.png (105.3 KiB)

It seems that you forgot to select the Release, x86 configuration.


0 Votes 0 ·

Thank you for your reminder, I can reproduce this issue in release mode as well. It's an interesting question. I'll need to ask other engineers about this. There might be some time delay.

1 Vote 1 ·

0 Answers