SL5 with AsyncCtp: The type ‘System.Threading.Tasks.Task’ exists in both mscorlib.dll and AsyncCtpLibrary_Silverlight.dll

If you use AsyncCtp With SL5, you could have the following issue: The type ‘System.Threading.Tasks.Task’ exists in both mscorlib.dll and AsyncCtpLibrary_Silverlight.dll.

So you can’t compile your project if you use Task class!

In this case, you could use an alias on the assembly but, you could not use async / await keywords.

I found a trick to do it: using two aliases on AsyncCtpLibrary_Silverlight. For this, in the aliases property of the assembly reference, I use “global,AsyncCtpLibrary” instead of only “global”.

Like this, I can use async/await because I have global alias on AsyncCtpLibrary_Silverlight.dll and I can use Task class with the following using:

extern alias AsyncCtpLibrary;


using AsyncCtpLibrary.System.Threading.Tasks;


 



Update:



Note that if you use AsyncCtpLibrary_Silverlight5.dll instead of AsyncCtpLibrary_Silverlight.dll, you don’t need to do it!

This entry was posted in 13461, 16710. Bookmark the permalink.

2 Responses to SL5 with AsyncCtp: The type ‘System.Threading.Tasks.Task’ exists in both mscorlib.dll and AsyncCtpLibrary_Silverlight.dll

  1. It’s Really work, I was spend my whole day due to this issue but with the help of this I got the solution.

    Thanks

  2. I was also try to use AsyncCtpLibrary_Silverlight5.dll but it gives error due to that my project didn’t get compiled.
    Using alias I got solution.

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>