How to Fix Windows.Storage Namespace Not Found Error
Add references to UWP dlls and winmd manually to access APIs
4 min. read
Updated on
Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more
Key notes
- While using Visual Studio for a portable class library project, many users may face an issue where the Windows.Storage namespace is not found.ย
- The issue seems to arise mostly due to an error on your end. For example, if you are not using the object browser correctly, or if you've not understood the error message.ย
- The trick lies in whether you are able to access the Windows APIs from WPF (Windows Presentation Foundation)ย and that's what the post focuses on.ย
When trying to build a UWP app you may sometimes realize that the Windows.Storage namespace is not found.
On a closer look, this issue arises mostly due to an error on your end, and that’s what we will discuss in further sections. But, if the UWP apps lag & stutter on your Windows 11 PC, you can refer to our post for some effective solutions.
What is Windows.Storage namespace?
Windows.Storage namespace is a collection of Windows APIs that offers classes for managing files, folders, and application settings.
The Microsoft official web page also explains how to use the objects in Windows.Storage namespace.
Why is Windows.Storage namespace not found?
Sometimes, while using Visual Studio you may encounter an issue like Windows.Storage namespace not available or not found. This could be due to any of the following reasons:
- If you are using the object browser incorrectly – The object browser is by default set to All Components which needs to be changed to what you have.
- You have not included the reference to the proper package – You won’t get access to the Windows.Storage namespace, unless you add the references to the correct package.
Note that the System.Windows.Storage is not the same as Windows.Storage. If the error message reads System.Windows.Storage (part of .NET & the root namespace for WPF), it’s different from Windows.Storage (root namespace for WinRT, the primary API for UWP apps).
How can I fix Windows.Storage Namespace Not Found error?
1. Add the references to UWP DLLs and WINMD files manually
- When using Visual Studio, go to Solution Explorer, right-click on References, and select Add Reference from the context menu.
- On the left side of the Reference Manager, click on Browse and navigate to the following path: C:Program Files (x86)Windows Kits10UnionMetadatawinmd
- Now, add it to your project as a reference. Also, make sure to change the filter to All Files.
- Again, right-click on References, and click on Add Reference from the context menu.
- Next, on the left of the Reference Manager, go to Browse and find the directory, C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETCorev4.5.
- Add System.Runtime.WindowsRuntime.dll to your project.
So, if you are unable to access Windows.Storage namespace, it could be possible that you have not added the reference to the proper package.
In this situation, you may feel that Windows.Storage namespace is not found. You would need to download the package following the above steps.
You can now build your own WPF application location-aware by calling on the Geolocator class in Windows.Devices.Geolocation API.
At the same time, you can also use the asynchronous pattern in UWP. This is because the classes and methods you usually consider as UWP code is now incorporated with classes and methods from WPF.
But, if the Windows.storage.dll crashes on your Windows PC, we recommend a list of solutions that may help you fix the issue quickly.
2. Use the object browser correctly
- By default, the object browser is set to All Components, hence, firstly, select NET Portable Subset (Visual Studio 2013).
- Next, to add the Windows.Storage, select All Components, and look for Windows.winmd.
- Now, Highlight the desired Component, and click on Add to References in Selected Project under Solution Explorer.
This will add the reference to the Portable Library project, and you can now use your StorageFolder in Class1.cs.
Alternatively, if you do not want to install the Windows Store at this moment, but simply want to use some of those Windows APIs, you can get them from your app. How?
Nevertheless, you can achieve this by using a NuGet package, also called asย UwpDesktop. To inspect theย source code, you can visit GitHub.
If you have any other queries related to a missing Windows API, let us know in the comments section below.
User forum
0 messages