Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to open the file dialog in my WPF application which is a .Net Core app and uses a .Net Standard Library where all my code lives. However, when I tried the OpenFileDialog() method which inherits from Microsoft.Win32 namespace, it says "the name OpenDialog does not exist in the current context" and that is the recurring error even after adding the namespace manually. However. when I tried this in my .netcoreapp, it works just fine. Bringing me to the conclusion that this is probably a problem with .netstandard only. My question is what is the best fix to this, I cannot put the code in my .NetCore WPF app, so the only other alternative is to create a new project for the sole purpose of opening the file dialog which I find a bit too much. Please does anyone have any alternatives, or perhaps I am doing things wrong. I would appreciate all your contributions.

What I have tried:

I tried downloading Microsoft.Win32 from nuget package manager but no luck
Posted
Updated 14-Apr-21 5:06am

1 solution

Looking at the "Applies to" section in the documentation, this dialog was never defined for .NET Standard:
Applies to:
  • .NET 5.0, 6.0 preview 3
  • .NET Core 3.0, 3.1
  • .NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

As further confirmation, if you select any version of .NET Standard in the "version" list on the left, you will get a message telling you that the requested page is not available.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900