C
C#•2y ago
Marvin

Issue with FolderBrowserDialog in console application

Hey, when I start my application via Visual Studio everything works, but as soon as I start the console application directly, I get the following error:
System.MissingMethodException: Method not found: 'Void System.Security.Permissions.RegistryPermission..ctor(System.Security.Permissions.PermissionState)'
System.MissingMethodException: Method not found: 'Void System.Security.Permissions.RegistryPermission..ctor(System.Security.Permissions.PermissionState)'
Code:
public static void OpenFileDialog()
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.ShowNewFolderButton = true;
if (fbd.ShowDialog() == DialogResult.OK)
{
foreach (var path in Directory.GetFiles(fbd.SelectedPath))
{
Console.WriteLine(path);
}
}
}
public static void OpenFileDialog()
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.ShowNewFolderButton = true;
if (fbd.ShowDialog() == DialogResult.OK)
{
foreach (var path in Directory.GetFiles(fbd.SelectedPath))
{
Console.WriteLine(path);
}
}
}
20 Replies
phaseshift
phaseshift•2y ago
console runtime does not have access to ui stuff. If you want UI, don't pick a console project
Marvin
MarvinOP•2y ago
but why then via visual studio?
phaseshift
phaseshift•2y ago
wat
Marvin
MarvinOP•2y ago
if i start the application with visual studio stuff (image), then it works.
Marvin
MarvinOP•2y ago
Marvin
MarvinOP•2y ago
and yup, it have the STAThread Attribute
phaseshift
phaseshift•2y ago
Oh. Are you copying your app to another machine or something?
Marvin
MarvinOP•2y ago
later then, not yet so yes, it is planned that others can use the programme. currently, however, it is only local to me. if that's what you meant
phaseshift
phaseshift•2y ago
Yes. What SDK/.NET version are you using ?
Marvin
MarvinOP•2y ago
netcoreapp3.1
phaseshift
phaseshift•2y ago
GitHub
MissingMethodException for System.Security.Permissions.SecurityPerm...
Looks like the issue I opened in https://github.com/dotnet/coreclr/issues/21742 probably belongs here. New in .NET Core 3.0 Preview 1 compared to 2.2 is a MissingMethodException for Void System.Sec...
phaseshift
phaseshift•2y ago
Seems relevant
Marvin
MarvinOP•2y ago
old stuff i think
Marvin
MarvinOP•2y ago
phaseshift
phaseshift•2y ago
yeah
Angius
Angius•2y ago
.NET Core 3.1 is old stuff, indeed
phaseshift
phaseshift•2y ago
or just update your net core 'net core' -> net 7
Marvin
MarvinOP•2y ago
sad will it fix the issue? 😂
Angius
Angius•2y ago
If it will - great If it won't - still great, you're up to date at least
Marvin
MarvinOP•2y ago
lol its not supported by them, but i never had issues like that. but im sure, it will change nothing xd whatever, thank you all
Want results from more Discord servers?
Add your server