1

I have a working Xamarin.Forms project that was building fine, when suddenly (after Visual Studio had been closed/reopened, presumably after some update), I started getting the following error:

Failed to resolve assembly: 'MYAPPNAME, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

How do I resolve this error? It doesn't give me a file or location where the problem is, & ProcMon doesn't appear to be helpful either.

1 Answer 1

2

Xamarin.Forms scaffolding apparently will sometimes build a circular assembly reference.

The broken reference will be in one of your XAML files and look like this:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" 
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:local="clr-namespace:MYAPPNAME;assembly=MYAPPNAME"
            ... />

The problem is that at some point Xamarin stuffed in the assembly=MYAPPNAME text.

In some cases, your previously built assembly is either gone/not usable, and therefore this assembly reference is trying to resolve itself before the project is ever built - i.e. it will never work.

Simply remove the bolded text above, save your XAML file, rebuild and everything should be fine - if you still get the same error, you may have other circular reference in other XAML files.

Bug with Xamarin/MSFT pending.

Sign up to request clarification or add additional context in comments.

5 Comments

If I remove the reference, the code stops working, because it needs to use a class defined in another namespace from the same Assembly.
@UlyssesAlves - you might want to try a clean/rebuild first, and maybe close/reopen VS. The local assembly reference shouldn't be necessary, as Xamarin assumes it references the project it was built in
I didn' work for me that way. The error here was just some nuget packages which were installed but somehow not being recognized as installed by Visual Studio, so the project wouldn't compile. I removed these packages and installed them again (actually just referenced the dlls paths directly, because the packages are deprecated and not available anymore on Nuget.org), and now the project has compiled successfully.
Here's a link to my answer to this error: stackoverflow.com/a/67520172/1639385
Thanks for your answer, having local set to xmlns:local="clr-namespace:MYAPPNAME" fix the issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.