async method compiler error on XAML projects that reference own assembly
-
7. března 2012 9:57
Yesterday I reported a problem in the parallel extensions to the NET. Frameworkd forum.
async await problem installing side by side VS 11 Beta with VS 2010
I've been eliminating elements of my project and now I can reproduce the problem. Now I think it is a problem of the Async Ctp and XAML projects in general. That is why I am now reporting in this forum.
First I uninstalled VS 11 Beta. Then VS 2010 had a problem at startup, so I had to repair its installation (but that is another problem that I have no time to investigate).
After succesful repairing VS 2010. The compiler reported another different error in asynchronous methods in some of my XAML projects.
I was removing elements and now I know how to reproduce the error.
Is quite simple:
1. Create a default WPF User Control project
2. Add a reference to the NET Async Ctp library
3. Add this lines to the default User Control behind code
using System.Threading.Tasks; namespace WpfControlLibrary1 { /// <summary> /// Interaction logic for UserControl1.xaml /// </summary> public partial class UserControl1 : UserControl { public async Task SomethingToDoAsync() { await TaskEx.Yield(); } public UserControl1() { InitializeComponent(); } } }
4. Build the project: no errors now
5. Insert the following line in the XAML of your user controlxmlns:own="clr-namespace:WpfControlLibrary1"
6. VS reports the error: "expected ; "
What has happened?
I think it has to do with the order in which the XAML projects compile assemblies when referring to classes of the library itself. In this case, the XAML Loader try to compile this classes before having reference to the Async CTP library. So, the keyword "async" is not recognized.
I think that the problem is not related to the installation of VS 11 Beta. But when it was installed the error was more explicit:
"Cannot find all types required by the 'async' modifier. Are you targeting the wrong framework version, or missing a reference to an assembly?"
¿Workarounds? I can imagine several but none like me.
¿Any ideas?
Thanks
- Upravený SERware 7. března 2012 10:07 spelling
Všechny reakce
-
7. března 2012 23:04
Did you try to re-install Async CTP 3?- Označen jako odpověď SERware 7. března 2012 23:45
-
7. března 2012 23:45
Thaaaaaaaaaaanks Yuri!!!
All is ok after re-installing Async CTP 3.
I didn't re-install Async CTP 3, because except those methods in projects with XAML, all
async methods compiled correctly.Perhaps the problem comes from side by side installation of VS 11 Beta and VS 2010 SP1 with Async CTP. I don't know.
It's a pity, but I'll have to install VS 11 Beta out of my development PC for testing.
Thanks again
-
8. března 2012 15:12
I believe you are right in your description of the problem.
I have 2 WPF/XAML projects.
My old simple test WPF/XAML GUI perfectly compiles with Async CTP.
However the production GUI with user controls and clr-namespace fails like in your case.
I agree that most probably the order of assembly compilation is indeed the root of the problem.
The question:
is it possible to split the GUI assembly with user controls and resolve the problem of the compilation order (at least for the time being)?
-
8. března 2012 18:43
Hi Yuri,
At last, I believe the source of the problem is the coexistence of VS 11 Beta and VS 2010 with Async CTP applied.
I believe all VS 2010 projects can be opened in VS 11 Beta, except if the VS 2010 projects have dependencies on Async CTP. In my case, I tried to open in VS 11 Beta a VS 2010 solution referencing Async CTP library: the error window was filled with weird messages.
That's normal: VS 11 Beta already incorporates out of the box everything you need for
async/await (and the new implicit environment can not coexist with the old Async
CTP library).Anyway, I have no time to investigate the problem.
As to your question, may be a manual build can do the magic, but you will loose intellisense, etcétera, etcétera.
My solution is: "don't test VS 11 Beta on the same machine if your production code depends on Async CTP."
There's another solution: "don't use a CTP for your production code...". I agree, but async/await is so cool, that I can´t "await" the oficial 4.5 release :)
Thanks again
-
8. března 2012 18:58One more thing, perhaps the problem with "clr-namespace: namespace" xmlsn clauses, belongs exclusively to VS 11 Beta and its new async/await environment (and not to the mere coexistence with VS 2010 and Asyn CTP). In this case, Microsoft is responsible for fix it, we have already done quite detecting when it occurs.
And as least for the time being... I'll have the problem testing my code in VS 11 Beta...
¿Any ideas?
Thanks
-
8. března 2012 20:11
-
8. března 2012 20:32
Hi Paulo,
Your information isolates the problem in the .NET 4.5 Beta. I found the problem in VS 2010, but the origin is in the new Framework. Therefore, following my steps, the problem must be reproducible in systems with .NET 4.5 Beta installed.
Thanks
-
8. března 2012 20:44If someone has this problem on an installation side by side of VS 11 Beta and VS 2010 SP1 with Async CTP 3, and wants to return to the previous state, this is a guide to do it:
1. Uninstall VS 11 Beta, .NET 4.5 and all related products
2. If after desinstallation there are problems starting VS 2010, repair VS 2010 installation.
3. Re-install Async CTP 3.
I believe that it is not necessary to reapply SP1, but it can be done for greater security.
Hope it helps
-
8. března 2012 22:39
-
8. března 2012 23:35
-
9. března 2012 0:33Here's from the man himself: Visual Studio 11 Beta currently incompatible with AsyncCtpLibrary*.dllPaulo Morgado
-
18. října 2012 9:16
Hi Paulo,
they didn't fixed the problem in the release version of the Studio 11, did they? :-(
I can't move to Studio 11 because I'm doing Windows Phone development..
-
18. října 2012 23:33
I don't think they did or that it will ever be a compatible version for Windows Phone 7.
I'm changing all my Windows Phone 7 apps from async/await to Rx.
Paulo Morgado -
24. října 2012 0:29

