Open kfrancis opened 1 year ago
Strange. I have tried to recreate this, but I can not find any scenario where I get that exception. Closest I have come is when using File based ResourceManager with AddFileResource. Almost seems like the Resources file (DLL) has not been created. If that is the case, clean and rebuild should fix it.
If not, Try to recreate resources files.
This should work!
Actually, looks like it might be a MAUI bug. https://github.com/dotnet/maui/issues/7443#issuecomment-1406701369
Oh, it sounds like your problem. Does it work if you disable the "Fast Deployment" setting? (I need to verify my sample project and see if I get it!)
This is happening to me with this package in Windows 10 VS 2022 17.5.3. However, the same project compiles and works fine in MAC.
The sample project also doesn't work in Windows but works in MAC.
@arahmancsd , so to understand.
@arahmancsd , so to understand.
- You successfully compile sample project in VS2022 in Windows?
- You deploy/run sample project with "Windows Machine" as target and you get "FileNotFoundException" on the resource file?
- If not, please describe every step.
@SirJohnK thanks, I am getting this error when running my project in Windows targeting Android and iOS. Surprisingly, I unchecked System.Exception from Debug menu and the project is working. Additionally, if you continue (F5) with the exception, the project keeps working. In both scenarios, the resource manager works fine.
In terms of exception, it is the same as stated in the question.
I have no idea at the moment If I can have a release build with that exception, but can check that later.
@arahmancsd , I am really trying, but I can not recreate this issue!
My setup:
@SirJohnK to give you a bit more detail. Here is an exception happening in the AddResource
function in the forked sample project.
{System.IO.FileNotFoundException: File name: 'LocalizationResourceManager.Maui.Sample.resources' at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(Assembly assembly, CultureInfo culture, Version version, Boolean throwOnFileNotFound)}
My setup is;
Windows 10 v22H2 b:19045.2965 Visual Studio 2022, v17.5.3 Android Emulator: Pixel 5 Android 13.0 / API 33
@arahmancsd , this is really strange!
Why does this work without any problem for me and most other users? The only thing I can come up with is that is something is different with your setup.
Hope it helps!
@SirJohnK I have the latest VS and latest workloads. The release also crashes at startup in iOS, couldn't check it in Android yet. My project is XF upgraded to MAUI.
@arahmancsd , do you still have the same issue with the sample project from this repo, built with VS2022 on Windows?
@SirJohnK I am experiencing the same error attached earlier with the latest VS 2022 on Windows 10.
@arahmancsd , can you clone or fork the library and test to add it to your solution and remove/comment out the verification row?
resource.GetString(string.Empty);
I added that row for file verification and maybe(!) sometimes the file is not accessible at that time. If this works, I will update the library att remove or move the check.
Disabling fast deploy does not work for me. Any solution for this ?
@FrankVDL2471 , I would really like to get to the bottom of this! Unfortunately I have never been able to recreate this issue.
Johan,
When creating a new project it seems to be working fine. So I'm also unable to reproduce the problem outside my project.
My build maching is a Windows 11 I'm targeting an Android 13 api level 33 on a Pixel 5 emulator.
Op ma 23 okt 2023 om 10:27 schreef Johan Svensson @.***
:
@FrankVDL2471 https://github.com/FrankVDL2471 , I would really like to get to the bottom of this! Unfortunately I have never been able to recreate this issue.
- Can you build and run the sample project?
- and/or can you create and recreate this in a test project, that you can share?
- What is your exact setup when getting this issue? (Build machine, target OS, device/emulator/simulator, Langague settings etc)
— Reply to this email directly, view it on GitHub https://github.com/SirJohnK/LocalizationResourceManager.Maui/issues/4#issuecomment-1774679020, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3PKFC63VJIX5TR2DIPT5TYAYS6VAVCNFSM6AAAAAAUQVLAJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUGY3TSMBSGA . You are receiving this because you were mentioned.Message ID: @.***>
@FrankVDL2471 , ok.
It seems the issue might be a bit bigger. Just found out that when running my code on an actual device, also the resourcedictionaries for the styles are triggering the same error.
I've removed all the resx files from my project , but still get the same error. In my log I can see this
Loaded assembly: /data/data/com.notokenapp.sjwing/files/.__override__/System.Text.Encoding.Extensions.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly nl-BE/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly nl-BE/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly nl-BE/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly nl-BE/System.Private.CoreLib.resources.dll
**System.IO.FileNotFoundException:** ''
[monodroid-assembly] open_from_bundles: failed to load assembly nl/System.Private.CoreLib.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly nl/System.Private.CoreLib.resources.dll
[libc] Requested dump for pid 20232 (tokenapp.sjwing)
As additional info to @SirJohnK - we're facing the same issue in every localized (multi-project) solution. That issue is only happening to us, when deploying in DEBUG Mode to a physical device. When deploying to an emulator, without the setting Break When Thrown
for CLR Exceptions
, the problem occurs, but is transparent. Disabling Fast Deployment doesn't solve that problem. Out commenting the probing neither:
public bool AddResource(ResourceManager resource)
{
try
{
//Verify access by attempting to get empty string
//resource.GetString(string.Empty);
//Access attempt was successful!
resources.Add(resource);
//Return successful status
return true;
}
catch (Exception)
{
//Access attempt was not successful!
return false;
}
}
For debugging we copied the LocalizationResourceManager into our project. It looks, like it happens when resolving the resource in the GetValue
-method:
Everything is there and loaded correctly, but under the hood, that exception is thrown. I've found a bunch of related Maui issues, but none of them gave us workaround for that. This one is the most likely related and merged to 7.0.1xx, but doesn't solve the problem. Currently we're on Maui 7.0.101.
For us this is quite anoying, because we've to debug on a physical device for network related stuff, which isn't available on an emulator.
Just started facing the same issue: **System.IO.FileNotFoundException:**
glad this has been resolved and will be waiting on the new release 🥳
We have just an English and a French, but in trying to use this project we're getting an exception:
This is the exception:
{System.IO.FileNotFoundException: File name: 'CabMdMobile.Maui.resources' at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext) at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(Assembly assembly, CultureInfo culture, Version version, Boolean throwOnFileNotFound)}
Not really sure why it's having a problem. The files are in the same place as your example, have the same name "AppResources", the settings for the files in the csproj seem to be the same as your sample as well.