Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InitializeComponent throws System.IO.FileNotFoundException #26166

Open
icefire1 opened this issue Nov 27, 2024 · 1 comment
Open

InitializeComponent throws System.IO.FileNotFoundException #26166

icefire1 opened this issue Nov 27, 2024 · 1 comment
Labels
t/bug Something isn't working

Comments

@icefire1
Copy link

icefire1 commented Nov 27, 2024

Description

New MAUI app throws FileNotFoundException when launched on Android 14.

The issue has been reported before at #7002 and #10821.

Clearing the .vs folder or adding <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> as suggested by the previous issues seems to have no effect.

I reproduced in Visual Studio Preview 17.13.77.2683 and Visual Studio 17.10.341.11210.

Steps to Reproduce

  1. Create a MAUI project
  2. Enable all Common Language Runtime Exceptions
  3. Run app against Android device. Android device must have different system language than English (United States) such as Dansk (Danmark)

Expected outcome: App launches with debugger attached without any exceptions
Actual outcome: App launches with debugger, but will break on InitializeComponent() in App.xaml.cs. After continuing past 5 exceptions the App runs as expected.

Link to public reproduction project repository

https://github.com/icefire1/ResourceFileNotFound9

Version with bug

9.0.0-rc.2.24503.2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

Set Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture before InitializeComponent runs. E.g. in CreateMauiApp().

If setting culture to invariant is not a viable option it is possible to get around the exception by ensuring *.resources.dll exists in the build output. One horrible way of achieving this is by:

  1. Create two class libraries in the solution called System.Private.CoreLib and System.Private.Xml
  2. In each class library add .resx files for the cultures you need (da-DK in our case)
  3. Reference the class libraries in your App csproj

Relevant log output

Full Debug output can be seen in the repro repo ResourceFileNotFound9/ResourceFileNotFound9.Droid/debug-output.txt

[monodroid-assembly] open_from_bundles: failed to load bundled assembly da-DK/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
[monodroid-assembly] open_from_update_dir: assembly file DOES NOT EXIST
[monodroid-assembly] open_from_bundles: failed to load bundled assembly da-DK/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
[monodroid-assembly] open_from_bundles: failed to load bundled assembly da-DK/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
[monodroid-assembly] open_from_update_dir: assembly file DOES NOT EXIST
[monodroid-assembly] open_from_bundles: failed to load bundled assembly da-DK/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
**System.IO.FileNotFoundException:** ''

...........

[monodroid-assembly] open_from_bundles: failed to load bundled assembly da-DK/System.Private.Xml.resources.dll
[monodroid-assembly] open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
[monodroid-assembly] open_from_update_dir: assembly file DOES NOT EXIST
[monodroid-assembly] open_from_bundles: failed to load bundled assembly da-DK/System.Private.Xml.resources.dll
[monodroid-assembly] open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
**System.IO.FileNotFoundException:** ''

...........
@icefire1 icefire1 added the t/bug Something isn't working label Nov 27, 2024
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant