Migration from new Xamarin project to .NET MAUI.Android failed to load assembly/dll

Wheelstring 150 Reputation points
2024-03-04T12:07:52.0466667+00:00

Hallo all

I create new project Mobile App (Xamarin.Forms) + link and USE my own dll (signed netstandard2.0 dll)

Run OK in Android emulator

I migrate this new project with tool "upgrade-assistant upgrade" to .NET 7 MAUI (all 3 project Base/Android/IOS) (dll are linked /Solution Explorer OK/ but NOT USED)

  • changed in MainActivity.cs/OnCreate> Xamarin.Essentials.Platform.Init(this, savedInstanceState); to Microsoft.Maui.ApplicationModel.Platform.Init(this, savedInstanceState);

Run OK in Android emulator

now in AboutPage.cs'constructor I use my function from dll:

InitializeComponent();

LabelName.Text = MyNamespace.MyClassName.MySpecEnum.MySpecEnumValue.ToString();

Build OK, but exception in Android emulator while app runnning:

System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

[monodroid-assembly] open_from_bundles: failed to load assembly MydllName.dll

Maybe/probably this error is connected with error:

Error XAGJS7028 System.IO.FileNotFoundException: Could not load assembly MydllName.dll, Perhaps it doesn't exist in the Mono for Android profile?¨

What should I do for using my dll? Thanks in advance!

It is completly a new project see screen

Shanghai

I am stuck :-(, Any help is appreciated.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,414 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 74,491 Reputation points Microsoft Vendor
    2024-03-14T09:49:28.0966667+00:00

    Hello,

    Do you know the best approach how to set MAUI (mayby WidthRequest and HeightRequest or) for FULL SCREEN of webview on any device?

    You can add x:name for webview.

    <WebView   
         BackgroundColor="Gray"
         x:Name="myWebview"
         
    >
    

    Then you can get the screen's width and height in the background code, After it, you can set it to the Webview.

    protected override void OnAppearing()
    {
         base.OnAppearing();
        myWebview.WidthRequest=DeviceDisplay.MainDisplayInfo.Width;
         myWebview.HeightRequest=DeviceDisplay.MainDisplayInfo.Height;   
    
    }
    

    By the way, please keep one thread for one question, it will help others have similar issue to find answer quickly.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.