Search code examples
visual-studioxamarinxamarin.formsxamarin.androidfile-not-found

System.IO.FileNotFoundException: Could not load assembly "AppName" after update xamarin forms


I can't rebuild the project and I'm getting this exception after updating to latest Xamarin Forms 3.4.0.1008975 , if I downgrade it to 3.1.0.583944 or lower the exception will gone and I can build successfully.

I've tried to update VS and clean - close - reopen but the problem still there , I also tried to move the project to C:/ but no luck .

Error       The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'SouqAlData, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'SouqAlData.dll'
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() SouqAlData.Android  

enter image description here


Solution

  • My understanding of the situation tells me that you do not have the latest version of Xamarin which comes along with Visual Studio 15.9.xx.

    And hence when you update your Xamarin Forms package to the latest version of that is available it sees a discrepancy in between the versions and hence might be throwing this. One more reason could be that when you update your Xamarin Forms package, somehow the path for your SouqAlData.dll is lost by VS and hence you get this error. What I would suggest you do in case two is that you provide the proper path for your .dll again to VS and see if that helps you build the project.

    You can give the path as follows:

    • Remove the existing reference to the .dll
    • In your project go to References>Add Reference>Browse then give it the .dll path from your solution directory.

    Update:

    From recent Xamarin forms update code behind doesn't support Task return type as signatures for event handlers.

    So Replacing the Task with Void return type did the trick. Reference