1

Though it is far from my choice, I'm forced to work with some libraries that were written in VB.Net. One of these libraries has some DTOs I'm looking to reuse in a Xamarin.Android project I'm working on. I've included the references just fine, but when I attempt to build, I get the following error:

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

Is anyone familiar with this issue, and is there a fix (preferably not involving the inclusion of that DLL)?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Michael
  • 4,010
  • 4
  • 28
  • 49

2 Answers2

2

I had the same issue and could overpass it by rebuilding the VB project after adding the following line:

<VBRuntime>Embed</VBRuntime>

to the PropertyGroup section of the file NameOfProject.VBPROJ (do it using Notepad, eventually). It will finally look something like this:

<?xml version="1.0" encoding="utf-8"?>
[...]
  <PropertyGroup>
    [...]
    <VBRuntime>Embed</VBRuntime>
  </PropertyGroup>
[...]

Some hint came from here:

http://blogs.msdn.com/b/lucian/archive/2010/01/29/core6-vb-core-make-the-vb-runtime-optional-without-breaking-ctype-c.aspx

Giovanni
  • 21
  • 3
1

You can also solve the problem by installing the package "Microsoft.VisualBasic" via NuGet.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Steve
  • 11
  • 2
  • Please also try to include why the error occurred or how this fixes the error as this might not be clear for everyone – David Medenjak Aug 06 '17 at 10:16
  • The package is pretty useless. It does not much methods/properties included that you would generally find in Microsoft.VisualBasic.dll. A better way would be to include it as reference like: ` C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Microsoft.VisualBasic.dll ` – Shashank Sood Mar 29 '23 at 20:14