Cannot find Task-related types. Are you missing a reference to 'AsyncCtpLibrary.dll' ?_

Locked Cannot find Task-related types. Are you missing a reference to 'AsyncCtpLibrary.dll' ?_

  • martedì 21 febbraio 2012 17:08
     
     

    I have downloaded the CTP and uninstalled previous versions.  I have VS2010 Sp1 Professional.  The install seemed to go fine and I have the dll and samples.  However, even the C# 101 sample gets the above error as well as any samples I have tried to create.  I opened the dll and it has the TaskAwaiter<T> method and the reference points to the correct directory.  I uninstalled everything, - checked for the KB* updates I saw referenced in the forums, installed the phone sdk (which I really don't need now) and re-installed.  Same thing.  Any help?

    I checked and this is the only AsyncCtpLibrary.dll on my system.  CSC version is 4.0.30319.517

Tutte le risposte

  • mercoledì 22 febbraio 2012 02:43
     
     

    What kind of project are you using (desktop, browser, phone)?

    What is the exact error you're getting?


    Paulo Morgado

  • mercoledì 22 febbraio 2012 03:17
     
     
    Desktop.  That is the exact error. "Cannot find Task related types. Are you missing a reference to AsynCtpLibrary.dll?"
  • mercoledì 22 febbraio 2012 04:09
     
     
    In the samples solution or any other solution you're trying to use the dll, open the references section and see if there's a yellow mark by the async library/dll.  This often happens when the location of the dll is not found in same location of the solution.  Just right click on it, delete the reference and add it back in using the proper location of the DLL. 

    JP Cowboy Coders Unite!

  • mercoledì 22 febbraio 2012 04:21
     
     
    Thanks but it was in the proper location and adding it back did not help.
  • mercoledì 22 febbraio 2012 16:46
     
      Contiene codice

    Can you write a very simple application that reproduces this?

    For example, this .NET Framework 4.0.2 Client Profile console application:

    namespace ConsoleApplication3
    {
        using System.Threading.Tasks;
    
        class Program
        {
            static void Main(string[] args)
            {
                Async().Wait();
            }
    
            static async Task Async()
            {
                await TaskEx.Yield();
            }
        }
    }
    
    Works with just a reference to AsyncCtpLibrary (version 1.0.4107.18181) (mscorlib is implicit).

    Paulo Morgado

  • mercoledì 22 febbraio 2012 17:57
     
     

    Ok so if references are correct the last thing to do is add the using statement in the code:

    using System.Threading.Tasks;


    Paulo showed this in the example above.


    JP Cowboy Coders Unite!

  • mercoledì 22 febbraio 2012 20:12
     
     

    from your example:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Runtime.CompilerServices;

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Async().Wait();
            }

            static async Task Async()
            {
                await TaskEx.Yield();
            }
        }
    }

    I get the following:

    Error 2 Missing compiler required member 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Create' 
    Error 1 Cannot find Task-related types. Are you missing a reference to 'AsyncCtpLibrary.dll' ?
    Error 3 'System.Runtime.CompilerServices.YieldAwaitable' does not contain a definition for 'IsCompleted'

    I feel like I have inconsistent versions, so I uninstalled, checked that I had no other AsyncCtpLibrary.dll laying around, then reinstalled ..still the same.

    Thanks for your help.

  • mercoledì 22 febbraio 2012 20:23
     
     
    I do have Silverlight 5 installed (from a message on another forum)
  • mercoledì 22 febbraio 2012 22:19
     
     Risposta suggerita
    Silverlight 5? If it's a Silverlight 5 application then you'll need to reference AsyncCtpLibrary_Silverlight5, not AsyncCtpLibrary.

    Paulo Morgado

  • martedì 28 febbraio 2012 20:33
     
     
    It is not a Silverlight App.  I was trying to compile the samples.  I have since uninstalled everything and now it won't re-install.  I had a sample program written in the old ctp version and was just trying to get anything working in order to evaluate potential usage in a real project.  I think I have now invested enough time in this and will just wait for a release version.