Forum Xamarin.Android

Exception Microsoft.VisualBasic with Visual Basic Portable Class Library, Framework 4.5, Async/Await

Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Microsoft.VisualBasic.dll'
in Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
in Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
in Xamarin.Android.Tasks.ResolveAssemblies.Execute()

The above exception is shown if you:

  • Create an Android app
  • Create a Visual Basic Portable Class Library targeting: .NET Framework 4.5, Windows 8, Windows Phone 8.1, Xamarin.Android
  • In the PCL add an instruction Async/Await such as:
    Public Class Class1
    Private Async Function Test() As Task(Of String)
    End Function
    End Class

  • Reference the PCL from the Android App

Removing Microsoft.VisualBasic reference from the PCL does not help.
If you do not use any Async/Await instruction, there is no exception.
If you target the PCL .NET Framework 4.0 and provide Async/Await by installing NuGet Microsoft.Bcl.Async, there is no exception.

Sign In or Register to comment.