Skip to content

Attempted to read or write protected memory. this is often an indication that other memory is corrupt #4167

@git102347501

Description

@git102347501

Env:

GUI: WinUi3
IDE: VS2022
System: Win11

Question:

I try to add the List content to the DataSource again after clearing the DataSource, and there is a chance to throw the following error:
Attempted to read or write protected memory. this is often an indication that other memory is corrupt

d6dea131713bd1e6931e44a35eaba66

My Code:

 public ObservableCollection<ExplorerItem> DataSource = new ObservableCollection<ExplorerItem>();
 public List<Object> List = new List<Object>();
 // ..
 this.DataSource.Clear();
 List.ForEach(c => DataSource.Add(new ExplorerItem() { 
      Name = c.Name,
      Id = c.Id
  }));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions