CSLA 4.5 DataPortalT.cs

CSLA 4.5 DataPortalT.cs

Old forum URL: forums.lhotka.net/forums/t/11559.aspx


tiago posted on Thursday, August 30, 2012

Hi Rocky,

I was having a look at  CSLA (Trunk 4.5.1.0) and VS2012 refuses to compile both Csla.Net4 and Csla.Silverlight (SL5) projects on the grounds:

'System.Threading.Tasks.Task' does not contain a definition for 'Run'

It's the only error I got on both projects.

Microsoft.CompilerServices.AsyncTargetingPack 1.0.0 is installed. Microsoft.CompilerServices.AsyncTargetingPack.Net4 and Microsoft.CompilerServices.AsyncTargetingPack.Silverlight5 references are all right.

It's a Windows 7 Pro system, fully updated.

After some investigation, I added a NET45 symbol to the Csla project and changed the offending line as follows:

#if NET45
  return Task.Run(() => dp.DoFetchAsync(objectType, criteria, true)).Result;
#else
  return TaskEx.Run(() => dp.DoFetchAsync(objectType, criteria, true)).Result;
#endif

Everything builds. Don't know if it runs :)

JonnyBee replied on Thursday, August 30, 2012

Hi,

Seems like you have the AsyncCTP installed (TaskEx) and not the latest AsyncTargetingPack.

I run on Windows 7 Pro with VS2012 Premium and AsyncTargetingPack.

Use NuGet to install the targeting pack into these projects.
Install-Package Microsoft.CompilerServices.AsyncTargetingPack

tiago replied on Friday, August 31, 2012

Hi Jonny,

Been there done that. Today I repeated the steps Uninstall-Package / Install-Package several times . Even cleared the proxy cache.

As a side note, since both the reference and the DLL were already there, the Install-Package operation made no changes. I must conclude this wasn't needed at all. Every now and again some guys at Microsoft come up with some brilliant ideas. This is a simple DLL and it should be possible to add a reference as we do for every other DLL. Forcing us to use the package manager to add a reference to a project is really brilliantly convoluted. I guess they won the 2012 Olympics gold medal for the most convoluted idea.

Back to the trunk sources, if you take a look at

Microsoft.CompilerServices.AsyncTargetingPack.Net4.xml

that is in

...\Source\packages\Microsoft.CompilerServices.AsyncTargetingPack.1.0.0\lib\net40

you will notice that around line 1778 TaskEx shows up. The respective DLL seems to know TaskEx also.

So... I feel confused. Any ideas?

JonnyBee replied on Friday, August 31, 2012

Mmmm,  must something that is added lately in the code that breaks the SL5 and .NET 4 projects.

So, yes - you are correct. We need to add compiler directives if this is the way to go.

I believe Rocky has been trying to find a way to make the sync portal use the async methods internally..
Just not sure if it is all working as it should yet.

tiago replied on Friday, August 31, 2012

I just wish to add that, since CSLA sources include the DLL and XML files, there is no need to install anything at all. Just tested with a fresh project.

Copyright (c) Marimer LLC