Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StorageProvider.TryGetWellKnownFolderAsync - System.AccessViolationException #17679

Closed
viktorspacil opened this issue Dec 3, 2024 · 1 comment · Fixed by #17705
Closed

StorageProvider.TryGetWellKnownFolderAsync - System.AccessViolationException #17679

viktorspacil opened this issue Dec 3, 2024 · 1 comment · Fixed by #17705

Comments

@viktorspacil
Copy link

Describe the bug

Hi,
when I call StorageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Downloads) in x86 compiled code then I am getting System.AccessViolationException. x64 compiled code is working ok. Earlier version of Avalonia (11.0.11) worked fine.

To Reproduce

call: var folder = await StorageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Downloads)

Expected behavior

No exception in x86 compiled code

Avalonia version

11.2.1, 11.2.2

OS

Windows

Additional context

No response

@stevemonaco
Copy link
Contributor

Looks like I introduced this in #17107 while fixing a regression.

x86 is having trouble with the SHGetKnownFolderPath call here:

private static unsafe string? TryGetWindowsKnownFolder(Guid guid)
{
nint path = IntPtr.Zero;
string? result = null;
try
{
var hr = SHGetKnownFolderPath(guid, 0, 0, &path);

And the signature:

[DllImport("shell32.dll")]
private static unsafe extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid id, int flags, nint token, nint* ppszPath);

I'm not sure what the culprit is here though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants