dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.66k stars 4.57k forks source link

WPF Store application failed to loads the output directory files due to wrong current directory #43126

Open mageshsankar opened 3 years ago

mageshsankar commented 3 years ago

Description

I have published WPF application in Store SampleBrowser, and it fails to load an document file(Books.xml - Build Action : Content, Copy to output directory: Copy Always) so application crash on loading xml document. Please find the below code how we have loaded xml document and exception screenshot below:

XDocument xDocument = XDocument.Load(@"Assets/TileView/Books.xml");

image

jaymin93 commented 3 years ago

It seems you are running this on arm Machine ( my assumption) but regarding the issue you have not supplied full path that's reason it's generating exception you may get path of executables using assembly.getexecuting assembly.location and then file name it should work fine

carlossanlop commented 3 years ago

Have you tried passing the full path of the file to XDocument.Load? Otherwise, Load will internally assume the file's root prefix path should be the location of wherever the executing process is (although I'm not sure why C:\Windows\SysWOW64 is showing up as the executing process location).