4
votes

I created a portable Class library, which should be used in a xamarin project, I removed the Microsoft.VisualBasic reference explicit in the Project. Using the library in the xamarin project causes the following compiletime error:

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?Dateiname: "Microsoft.VisualBasic.dll" bei Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) bei Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel) bei Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel) bei Xamarin.Android.Tasks.ResolveAssemblies.Execute()

When I inspected the .dll-file with the dependency walker (ildasm.exe), I noticed, that Microsoft.VisualBasic is listed as dependency:

.assembly extern Microsoft.VisualBasic
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 10:0:0:0
}

Can anybody tell me the reason why Microsoft.VisualBasic is still a dependency of the class library and how to solve this issue?

Thanks Ced

2
Are you creating a VB PCL? It is a valid way to create a PCL vs. the C# PCL. Otherwise we will need to see some steps of how you created this PCL.Jon Douglas
Yes it's a VB PCL. I created it this way File -> New Project -> Class library (Portable) Then I selected Net Framework 4.5, Windows 8. ASP.NET CORE 1.0, Windows Phone 8.1 as target. Finally I removed Microsoft.VisualBasic from the referencesCed
I think our docs on this topic should help: developer.xamarin.com/guides/cross-platform/… and developer.xamarin.com/guides/cross-platform/… There are quite a few gotchas here, so please read carefully!Jon Douglas

2 Answers

0
votes

Was curious since I haven't tried this before. Found some details that may help after some digging turns out there is a compiler option you can use -novbruntimeref (Old Code Project Article). Searching for that text give a couple leads that indicates that you can alternatively manually edit the project file and add line to the property group do the same thing.

<NoVBRuntimeReference>On</NoVBRuntimeReference>

Though some pages had the value as "true" instead of "on". But haven't tested it.

0
votes

You've to change the compilation options. Just switch Option Strict to "On" and the compiler will not bind Microsoft.Visualbasic. It depends on the late binding option which is a feature of vb.net and sometimes a problem!

Xamarin rocks ...