question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding SwipeItems to a SwipeControl from code-behind throws an AccessViolationException

See original GitHub issue

Describe the bug I have been trying to add a SwipeControl to a StackPanel from a C# code-behind. Doing everything from XAML works as expected, but doing the exact same in C# always throws an AccessViolationException when attempting to add a new SwipeItem to SwipeControl.LeftItems (or any of the other four directions).

I also tried not setting LeftItems in the ‘constructor’ (not sure what it’s called) and not setting it at all. The former resulted in the same error, and the latter threw a NullReferenceException as expected.

Steps to reproduce the bug

var swipeControl = new SwipeControl()
{
    LeftItems = new SwipeItems()
    {
        Mode = SwipeMode.Execute
    }
};
swipeControl.LeftItems.Add(new SwipeItem() {
    Text = "Dismiss",
    IconSource = new SymbolIconSource()
    {
         Symbol = Symbol.Forward
    }
});

Expected behavior WinUI should not throw an AccessViolationException.

Version Info

NuGet package version: Microsoft.UI.Xaml 2.4.2 Microsoft.UI.Xaml 2.5.0-prerelease.200708003

Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

This should be a separate issue, but without native or mixed debugging enabled, the real exception is hidden behind a non-descriptive COM exception. The only information that can be extrapolated from that COM exception is which assembly it’s coming from (which in this case is Microsoft.UI.Xaml)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
StephenLPeterscommented, Jul 30, 2020

This is on my radar but I haven’t had the time to investigate it yet. I’m sorry.

0reactions
github-actions[bot]commented, Jul 29, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AccessViolationException Class (System)
An AccessViolationException exception is always thrown by an attempt to access protected memory -- that is, to access memory that is not allocated...
Read more >
c# - Programs randomly getting System. ...
The error is being thrown by the IBM iDbAccess library, and happens consistently when debugging. If I do not step through, my error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found