1

I have an application that is being installed from MSIX installer. It is installing successfully, but when execute it after installation i get an error that there is no such a file in C:/UserName/AppData/Roaming/MyApplication.

What i have tried:

  1. Creating the folder (from C# code) on the very beggining of the application.

Result: It was creating it somewhere, but i couldnt see it on a disk apparently. Even when i tried creating files in that directory, i could do it without exception. So im sure that this folder existed. Somewhere. When i ran application from MSIX it gave me previously mentioned exception.

  1. I created folder from the OS manually to see if the error will persist.

Result: I ran application from MSIX and everything worked fine.

  1. At the last step i tried to access priviliges to the C:/WindowsApp folder (thats where MSIX are installing things), and i tried to run application from there manually by executing .exe (not by MSIX like previous times), to see if the error will last.

Result: It created those folders without problems, and application worked fine.

Any ideas what im doing wrong, or what i could do avoid this error ?

PS. I cannot change location of path C:/UserName/AppData/Roaming/MyApplication, because it is being created by 3rd parties dll's (Devexpress).

Bartosz Olchowik
  • 1,129
  • 8
  • 22

1 Answers1

2
  1. Try searching for the files under this path:

C:\Users\User\AppData\Local\Packages(hash)....

That is where all MSIX packaged apps redirect their AppData resources.

However, if the files are found to be existing in the "real" AppData folder, the app will work with that copy, not the one from the virtualized location (this is international behavior from Microsoft, to smoothen the transition of apps from classic installers to MSIX). That is why the application worked after you created the folder manually.

Also, note that the files from the virtualized location are accessible only to your application and can't be accessed by others from the machine.

  1. I suspect that when run the EXE directly from the install folder (not from the start menu entry point) the OS does not launch app in the container of the MSIX package, so none of the rules of running as a packaged-app apply. Therefore you can ignore this scenario.

Go back to #1 and try searching for the files under the path I mentioned. How are you (Devexpress) accessing the AppData path? I assume they are using something in the lines of (this should be ok):

Environment.GetFolderPath(Environment.SpecialFolder.)
Bogdan Mitrache
  • 10,536
  • 19
  • 34
  • I need some more time to figure out if its true. Can i guess the full name of that path ? Under Environment.SpecialFolder. I see no hashes in the path to the AppData Roaming. And anyway i think it will be hard to understand what happening. Highly doubt that Devexpress would make references with hardcoded paths, but somehow it throws error that files are not existing. And if Devexpress want to delete them, it probably had to create them before. Anyway, your reply is kinda usefull and is explaining some things about my doubts. Thank you. – Bartosz Olchowik Apr 12 '22 at 07:35
  • Checked it out, and it seems its just like you described it. I marked your question as solution for my problem, since it moved me forward to the right direction. Again, thank you for your reply. I dont know if you down voted my question, but if you did, please provide in comment some details, what i could do better. – Bartosz Olchowik Apr 12 '22 at 14:58
  • 1
    Great, glad I could help. No, I didn't downvote it, probably another user who didn't understand the problem you have. MSIX is still relatively new to most developers – Bogdan Mitrache Apr 13 '22 at 14:50
  • Many thanks for clarification of this mystery, why "external full path" is either under [Windows.Storage.ApplicationData.Current.LocalCacheFolder](https://learn.microsoft.com/en-us/uwp/api/windows.storage.applicationdata.localcachefolder)\Roaming or is under Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) – Miha Pirnat Jul 03 '23 at 13:47