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

Avalonia DevTools crash app on Windows on corporate laptops #15708

Closed
drweb86 opened this issue May 13, 2024 · 9 comments
Closed

Avalonia DevTools crash app on Windows on corporate laptops #15708

drweb86 opened this issue May 13, 2024 · 9 comments

Comments

@drweb86
Copy link

drweb86 commented May 13, 2024

Describe the bug

Avalonia.Diagnostics.Conventions crashes on corporate notebooks. I don't understand the reason. It tries to create folder that is already there C:\Users\SiarheiKuchuk\Pictures\Screenshots and fails.

   at Avalonia.Diagnostics.Conventions.get_DefaultScreenshotHandler()
   at Avalonia.Diagnostics.DevToolsOptions..ctor()
   at Avalonia.DevToolsExtensions.AttachDevTools(TopLevel root)
   at butil_ui.Views.MainWindow.InitializeComponent(Boolean loadXaml, Boolean attachDevTools) in D:\Personal\sources\butil\sources\butil-ui\obj\Debug\net8.0\Avalonia.Generators\Avalonia.Generators.NameGenerator.AvaloniaNameSourceGenerator\butil_ui.Views.MainWindow.g.cs:line 29
   at butil_ui.Views.MainWindow..ctor() in D:\Personal\sources\butil\sources\butil-ui\Views\MainWindow.axaml.cs:line 9
   at butil_ui.App.OnFrameworkInitializationCompleted() in D:\Personal\sources\butil\sources\butil-ui\App.axaml.cs:line 38
   at Avalonia.AppBuilder.SetupUnsafe()
   at Avalonia.AppBuilder.Setup()
   at Avalonia.AppBuilder.SetupWithLifetime(IApplicationLifetime lifetime)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action`1 lifetimeBuilder)
   at butil_ui.Desktop.Program.Main(String[] args) in D:\Personal\sources\butil\sources\butil-ui.Desktop\Program.cs:line 22
Avalonia.Diagnostics
Could not find file 'C:\Users\SiarheiKuchuk\Pictures\Screenshots'.
   at System.IO.FileSystem.CreateDirectory(String fullPath, Byte[] securityDescriptor)
   at System.IO.Directory.CreateDirectory(String path)
   at Avalonia.Diagnostics.Conventions.get_DefaultScreenshotsRoot()
   at Avalonia.Diagnostics.Screenshots.FilePickerHandler..ctor(String title, String screenshotRoot)
   at Avalonia.Diagnostics.Screenshots.FilePickerHandler..ctor()
   at Avalonia.Diagnostics.Conventions..cctor()
System.Private.CoreLib

To Reproduce

That's the first time i see it. It is not reproduced at home and at my own laptop.

Expected behavior

No error obviously, but also showing real error would be nice.

Avalonia version

11.0.10

OS

Windows

Additional context

NA

@drweb86 drweb86 added the bug label May 13, 2024
@drweb86
Copy link
Author

drweb86 commented May 13, 2024

When i launch app via Ctrl+F5 - it works fine.

@drweb86
Copy link
Author

drweb86 commented May 13, 2024

Basically idea is to add support for corporate environments?

@jp2masa
Copy link
Contributor

jp2masa commented May 13, 2024

For reference: #14069.

@stevemonaco
Copy link
Contributor

Conventions.DefaultScreenshotsRoot should probably return null on exception and/or we need fallbacks. It is always accessed on startup regardless of config, so if it fails, then it's fine if SuggestedStartLocation gets set to null. Better than always crashing with no mitigation. I'm not a fan of I/O in a property getter either.

I'm still unsure what the system configuration issue is though since the directory is supposed to exist on @drweb86's system.

@thevortexcloud
Copy link
Contributor

I am guessing OneDrive is involved somehow and there is some weird folder redirection happening.

@drweb86
Copy link
Author

drweb86 commented May 16, 2024

Directory is indeed exists. And yes, OneDrive create symbolic links to other directories.

@workgroupengineering
Copy link
Contributor

As the docs explain, Directory.CreateDirectory ensure that the folder exists (eg: Linux does not have Screenshots folder) and creates it if it is not found.

Create a simple console app with this code and check if it works

                var dir = System.IO.Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Screenshots");
                Directory.CreateDirectory(dir);

@drweb86
Copy link
Author

drweb86 commented May 16, 2024

Hi. Bug stopped to reproduce since today. I don't know why. Probably Microsoft Defender was blocking it. I tried to delete screenshots folder and it still works. Also I tried to rename folder. First time - name remains the same, from second time - it gets changed. And anyway in this case it also works fine.

Console app also works good.

@timunie
Copy link
Contributor

timunie commented May 17, 2024

closing as not reproducible anymore.

@timunie timunie closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants