radimitrov / CSharpShellApp

77 stars 18 forks source link

Error in CSharpShellCore.Utils.get_Assets() ? #341

Open Alisis33 opened 7 months ago

Alisis33 commented 7 months ago

The code to access a file in assets folder has not changed, but the Maui version crashes on program start. The text could not be copied, the text below is a OCR and could have errors. I am not sure yet what caused the error exactly.

App crashed 

System.TypelnitializationException: The type initializer for Test.Language'’ threw an exception. 
--> Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference 

at System.Object.CallSite.Target(Closure , CallSite , Object ) 

at System.Dynamic. UpdateDelegates. UpdateAndExecute1 [Object, Object] (CallSite site, Object arg0) 

at CSharpShellCore.Utils.get_Assets() 

at Test.Language.LanguageGet(String defaultLang) 

at Test.Language..cctor() 

End of inner exception stack trace — 

at Test.App..ctor() 
radimitrov commented 7 months ago

Most of the methods under CSharpShellCore.Utils abstract away stuff using the current Activity, which will be null before it is opened there. I will make the Assets property work without that, though.

Alisis33 commented 6 months ago

Not work in 3.2.34

radimitrov commented 6 months ago

It should work and did so when I tested it last month. Unfortunately it seems like I deleted the test project so I can't reconfirm. At which point in the startup cycle are you trying to access assets? To clarify, you need to update the APK plugin and then rebuild said app.

radimitrov commented 6 months ago

No, wait. You are using an old pre .NET 7 build of the IDE? I'm not 99% certain the plugin existed then, however updating it wouldn't work since the IDE and it will have different BCL.