MSBuild does not find asynchronous requested links

We have Visual Studio 2010 SP1 and Async CTP (SP1 update).

The solution with projects using the async/await keywords builds OK when building from the VS IDE. Also when building with devenv /build "Debug" solution.sln everything is fine.

However, msbuild @commands.rsp solution.sln reports:

 File.xaml.cs(123): error CS1993: Cannot find all types required by the 'async' modifier. Are you targeting the wrong framework version, or missing a reference to an assembly? 

commands.rsp is as follows:

 /nologo /p:Configuration=Debug /m:3 /fileLogger 

Any clues?

+6
source share
2 answers

Please refer to the discussion here: http://social.msdn.microsoft.com/Forums/uk-UA/async/thread/3d491cb0-a19f-4faf-80a6-5fd05e4e06db

There are two questions that need to be clarified in order to better understand your problem:

  • Environment: did you install VS11 side by side with VS 2010 + Async CTP?
  • Your project: do you have XAML with user controls and "clr-namespace" in your project?

I will give a preliminary conclusion of SERware from a discussion on the MS forum:

I think this is due to the order in which XAML projects compile assemblies when accessing the classes of the library itself. In this case, the XAML Loader will attempt to compile these classes before referencing the Async CTP library. Therefore, the keyword "async" is not recognized.

Personally, I'll see if the assembly can be split to allow dependency compilation order in XAML

Added after further research: As I found out, the explanation is even more disappointing: .NET 4.5 (beta) replaces .NET 4.0. In addition, asynchronous / pending type signatures have been internally changed. Therefore, there is still no way to use both VS 2010 + AsyncATP and VS11 Beta. - Yuri S. 2 minutes ago

+4
source

I was struck by this myself, and for various reasons I can not upgrade projects to .NET 4.5, so I had to develop a workaround.

Since this is only a problem for XAML projects that has an xmlns declaration pointing to itself, I can use async for all other referenced projects. This means that my architecture is still using async / await and is ready to migrate to .NET 4.5 later.

But in the affected XAML projects, I simply manually (poorly) implement things that are otherwise executed by the compiler.

So, the code that was previously clean:

 try { var foo = GetFoo(); foo.DoStuff(); var data = await foo.GetDataAsync(); bar.WorkOnData(data); } catch (Exception ex) { // Logging, throw up a popup, whatever... HandleError("Failed to get data", ex); } 

Now it will be as follows:

 var foo = GetFoo(); foo.DoStuff(); var getDataTask = foo.GetDataAsync(); getDataTask.ContinueWith(t => { if (t.IsFaulted) { // Logging, throw up a popup, whatever... HandleError("Failed to get data", t.Exception); return; } if (t.Status == TaskStatus.RanToCompletion) { bar.WorkOnData(t.Result); } }); 

Not ideal, of course, and this is what async/await was created for the solution. But this works as a short-term workaround, at least for the simple use of await .

0
source

Source: https://habr.com/ru/post/910159/


All Articles