Problem in using .DLL class library

surajRMsurajRM INMember ✭✭
edited December 2013 in Visual Studio

I have created .dll class library in visual studio 2013 ultimate. I want to use this library in my xamarin android project
It is giving following error

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Microsoft.Threading.Tasks.dll'
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() (test)

Posts

  • prashantvcprashantvc USXamarin Team Xamurai

    @surajRM

    I guess your class library project targets .Net 4/4.5 profile, in order to use the libraries within the Xamarin.Android project you need to create Android library Project or PCL project targeting Xamarin profiles.

  • mhutchmhutch USMember, Xamarin Team Xamurai

    This error indicates that a library you're using references Microsoft.Threading.Task.dll, so you need to reference it too. It's not part of the BCL, so you'd need to obtain it elsewhere e.g. NuGet.

  • surajRMsurajRM INMember ✭✭

    Sorry , prashantvc but I didnt get whatever you are telling.Can you tell me detail steps for that?

  • PouyaJavadzadehPouyaJavadzadeh USMember ✭✭

    Hey @prashantvc,
    Can you please explain how can it be done?

    I guess your class library project targets .Net 4/4.5 profile, in order to use the libraries within the Xamarin.Android project you need to create Android library Project or PCL project targeting Xamarin profiles.

  • AlexEnrquezAlexEnrquez ECMember

    It works for me
    http://www.scriptscoop2.com/t/74d90e64a3f0/monotouch-microsoft-threading-tasks-extensions-in-xamarin-mono-projects.html

    Open your Package Manager Console, and run the following commands:
    1) Uninstall-Package Microsoft.Bcl.Async -Force
    2) Install-Package Microsoft.Bcl.Async -Version 1.0.16

    It works in a sample I'm currently writing. Please let me know if it works for you.

    UPDATE (March 21st): You can update the package (new version 1.0.166-beta is available - https://www.nuget.org/packages/Microsoft.Bcl.Async/1.0.166-beta).
    I tested it on VS2013 with .NET 4.5 framework and it works.

  • PouyaJavadzadehPouyaJavadzadeh USMember ✭✭

    Hi @AlexEnrquez,

    I build my project either using 'PCL 4.5 - Profile 78' or 'PCL 4.5 - Profile 7' on Microsoft Visual Studio Enterprise 2015. It is not the first time I am facing this issue and till now I couldn't find any workaround for it! I even raised support ticket for Xamarin but I couldn't make any progress to resolve this issue . . . Just to say that our project could almost be failed due to this issue!

    You can check the history of this issue on Xamarin or Stack Overflow . . . also two reports here and here (with VERIFIED FIXED status! funny, isn't it?) Long story short I have tried your workaround and still suffering from the same issue . . . here some information that may come handy for you to dig-up more into it . . .

    Here is the error:

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

    Here is output from Package manager console:

    Install failed. Rolling back...
    Package 'Microsoft.Bcl.Build.1.0.14' does not exist in project 'Test.Droid' Install-Package : Could not install package  Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
    
  • TrevorDanielTrevorDaniel USMember

    I am suffering the same problem as described in the post above.

    I am running VS 2015 Community....

    I cannot seem to find a way to solve it.

    Can anyone help please?

  • SnappieSnappie NLMember

    I was running VS2015 Enterprise
    The problem for me was that Microsoft.Bcl.Async was not automatically installed, even though many of the automatically generated methods make use of it.

  • Tamer.AhmedTamer.Ahmed USMember ✭✭

    I have the same problem :(

Sign In or Register to comment.