Skip to content

Assembly load error in Android app referencing another project referencing a DLL assembly #10154

Closed

Description

@ist-22

Description

If a MAUI Android project has a reference to a .NET Standard project in the same solution; and the .NET Standard project has a reference to a .NET Standard assembly, calling a code that eventually calls a code in the assembly fails to load the assembly.

Steps to Reproduce

  1. Create a new MAUI solution and project.
  2. Add a .NET Standard project to the solution.
  3. Add a .NET Standard assembly reference to this project created in Step 2.
  4. Add a method to the .NET Standard project (created in Step 2) that calls something in the referenced (in Step 3) assembly.
  5. Add a project reference to the MAUI app that was created in Step 1 that references to the project created in Step 2.
  6. Call the method that was created in step 4.

i.e. The reference chain: MAUI csproj --> .NET Std. csproj --> .NET Std. DLL

Link to public reproduction project repository

https://github.com/ist-22/10154-repro
app has a project reference to lib1
lib1 has an assembly reference to lib2 (so lib2 needs to be compiled first)

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11

Did you find any workaround?

Add the .NET Standard assembly reference also to the MAUI app project.
In the repository uncomment lines 14..18 in app/app.csproj -- this adds an assembly reference to lib2 in app

Relevant log output

No response

Activity

  1. drasticactions commented on Sep 16, 2022

    @drasticactions
    Contributor

    Are you sure this is a MAUI (The UI Framework) issue, or an issue with whatever device you're trying to target? Did you try doing this with a dotnet new android app?

  2. ist-22 commented on Sep 16, 2022

    @ist-22
    Author

    I don't think it's a device/target issue (if this implies architecture) since adding a reference to the assembly in the top MAUI app can act as a workaround.

    However, you are right about the MAUI/UI framework question and pointing to the Android project. Yes the issue happens in a project created with dotnet new android, too; so I guess it's not MAUI specific and maybe more related to Xamarin.Android?

  3. ghost added
    s/needs-attentionIssue has more information and needs another look
    on Sep 16, 2022
  4. ghost removed
    s/needs-reproAttach a solution or code which reproduces the issue
    on Sep 16, 2022
  5. jonpryor commented on Sep 26, 2022

    @jonpryor
    Contributor

    Could you please attach a project that exhibits this scenario?

  6. added
    s/needs-reproAttach a solution or code which reproduces the issue
    on Sep 26, 2022
  7. ist-22 commented on Sep 29, 2022

    @ist-22
    Author

    @jonpryor -- Updated the issue description with the repo link

  8. ghost added
    s/needs-attentionIssue has more information and needs another look
    on Sep 29, 2022
  9. ghost removed
    s/needs-reproAttach a solution or code which reproduces the issue
    on Sep 29, 2022
  10. 25 remaining items

  11. jonathanpeppers commented on Jan 22, 2023

    @jonathanpeppers
    Member

    The first attempt to fix this in xamarin/xamarin-android/main didn't work out. (It caused a different issue) Reopening to look into this further.

  12. ghost locked as resolved and limited conversation to collaborators on May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions