New Posts New Posts RSS Feed: NEW: Cocktail Async Pack for Visual Studio 2012
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

NEW: Cocktail Async Pack for Visual Studio 2012

 Post Reply Post Reply
Author
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Topic: NEW: Cocktail Async Pack for Visual Studio 2012
    Posted: 03-Jun-2012 at 11:47pm

UPDATE: Version 1 has been officially released. There are separate NuGet packages for .NET and Silverlight. See updated link below.


For those of you eager to try the new async language features in C# 5 and Visual Basic 11, I’ve created just the thing for you. Announcing the “Cocktail Async Pack for Visual Studio 2012”.

 

The "Cocktail Async Pack for Visual Studio 2012" enables Cocktail/DevForce projects targeting .NET Framework 4.0 or Silverlight 5 to use the Async language feature in C# 5 and Visual Basic 11. This pack requires Visual Studio 2012 and will not work with Visual Studio 2010.

 

The Pack is available via NuGet and the source code is hosted on github. The NuGet package assumes that you are already using Cocktail, so it doesn’t bring the Cocktail package down with it, but it brings down the “Microsoft Async Targeting Pack for Visual Studio 2012”, which is required in order to use the new language features in .NET 4.0 and Silverlight 5.

 

NuGet: http://www.nuget.org/packages/Cocktail.AsyncPack

NuGet: http://nuget.org/packages?q=Cocktail

Github: http://github.com/IdeaBlade/Cocktail.AsyncPack

 

With the “Cocktail Async Pack” added to a project, all Cocktail and DevForce asynchronous operations become awaitable as in the following example. Check it out, play around with it and let me know what you think.

 

    [Export]

    public class MainPageViewModel : Screen

    {

        private IDialogManager _dialogManager;

        private NorthwindIBEntities _manager;

 

        [ImportingConstructor]

        public MainPageViewModel(IDialogManager dialogManager)

        {

            _dialogManager = dialogManager;

            _manager = new NorthwindIBEntities();

        }

 

        public async void SampleAction()

        {

            var customers = await _manager.Customers.Where(c => c.Country == "UK").ExecuteAsync();

 

            await _dialogManager.ShowMessageAsync(string.Format("Found {0} customers.", customers.Count()), DialogButtons.Ok);

 

            var employees = await _manager.Employees.ExecuteAsync();

 

            await _dialogManager.ShowMessageAsync(string.Format("Found {0} employees.", employees.Count()), DialogButtons.Ok);

        }

    }

 

 



Edited by mgood - 16-Aug-2012 at 4:26pm
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 05-Jun-2012 at 6:40pm
As an example, I've converted TempHire over to take full advantage of the new features in the "Cocktail Async Pack". The Silverlight version of TempHire has been converted to Silverlight 5 for this sample. Looks like Microsoft still has a few build kinks to work out. If the build fails, build again. It should successfully build the second time around.

Download the sources from github to see it: https://github.com/IdeaBlade/Cocktail.AsyncPack
Back to Top
jkattestaart View Drop Down
Newbie
Newbie


Joined: 30-Jul-2010
Location: Netherlands
Posts: 37
Post Options Post Options   Quote jkattestaart Quote  Post ReplyReply Direct Link To This Post Posted: 06-Jun-2012 at 10:31am

Hi, that looks promising.

Did you use Windows 8 RC, because in de Windows 8 i get the following error. The dll is there, but the build fails.

Error 1 The "EntityModelMetadataDeploy" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Shell, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.Shell, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Server stack trace:
   at IdeaBlade.VisualStudio.DTE.ServiceProviderHelper.GetServiceProvider(DTE2 dte)
   at IdeaBlade.VisualStudio.DTE.ServiceProviderHelper.GetProjects(DTE2 dte)
   at IdeaBlade.VisualStudio.DTE.DTEHelper.GetProjectByFileName(String pFileName)
   at IdeaBlade.VisualStudio.Build.Tasks.EntityModelMetadataDeploy.Execute()
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Build.Framework.ITask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
 DomainModel (DomainModel\DomainModel)

Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 06-Jun-2012 at 11:01am

DevForce does not currently appear to work in a standalone installation of Visual Studio 2012. We are currently investigating if Microsoft changed something from Beta to RC, or if there's something else going on. We do know that parts of Visual Studio 2012 RC currently require a side-by-side installation with VS 2010. This should all be resolved by the time RTM hits according to Microsoft. So far things seem to work as long as you have a side-by-side installation of VS2012 and VS2010.

Back to Top
jkattestaart View Drop Down
Newbie
Newbie


Joined: 30-Jul-2010
Location: Netherlands
Posts: 37
Post Options Post Options   Quote jkattestaart Quote  Post ReplyReply Direct Link To This Post Posted: 06-Jun-2012 at 11:40am
OK, indeed i did not install VS2010 in windows 8.
Thanks i will check this out.
Back to Top
Thomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21-Feb-2012
Posts: 23
Post Options Post Options   Quote Thomas Quote  Post ReplyReply Direct Link To This Post Posted: 17-Aug-2012 at 1:55pm
In the release version of visual studio 2012 there is still the same problem. Is there a timeline for when to expect a fix? This is also not a Cocktail error but a general DevForce problem.


Edited by Thomas - 17-Aug-2012 at 1:55pm
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 17-Aug-2012 at 4:07pm
Visual Studio 2012 will be fully supported in DevForce 2012 and Cocktail v2. You are looking at a September/October timeframe.
Back to Top
stage View Drop Down
Newbie
Newbie


Joined: 17-Aug-2012
Posts: 5
Post Options Post Options   Quote stage Quote  Post ReplyReply Direct Link To This Post Posted: 21-Aug-2012 at 6:51pm
I have no issues with Windows 8 RTM and standalone VS2012. However, in a shared code WPF / Silverlight project, you can not use NuGet to load the Cocktail Silverlight package and have to add the references manually.

The exception is:

Install-Package : Could not install package 'Cocktail.Silverlight 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain
any assembly references that are compatible with that framework.
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 21-Aug-2012 at 7:05pm
If you have a shared solution you need to apply the right package to each of the projects. You can't apply the .NET package to all the projects and vice versa. You have to apply the right package to the right project type. You only get this error message if you are trying to apply a package to the wrong project type.
So, to a .NET 4 project you need to add "Cocktail Async Pack for VS 2012 (.NET 4)" and to a Silverlight project you need to add "Cocktail Async Pack for VS 2012 (Silverlight)". Are you saying that doesn't work?
Back to Top
stage View Drop Down
Newbie
Newbie


Joined: 17-Aug-2012
Posts: 5
Post Options Post Options   Quote stage Quote  Post ReplyReply Direct Link To This Post Posted: 21-Aug-2012 at 7:18pm
I had never paid any attention to this previously but there is a Default Project dropdown in the Package Manager Console. Changing it to one of the Silverlight projects before running the Silverlight install resolved this. Thanks for your help.
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 21-Aug-2012 at 9:36pm
If you use the Package Manager Console and you have multiple projects in your solution you should specify the project when installing a package. If you don't then it installs it to the default project selected in the drop down. The following are all the command line options.

Install-Package [-Id] <string> [-IgnoreDependencies] [-ProjectName <string>] [[-Version] <string>] [[-Source] <string>] [-IncludePrerelease] [<CommonParameters>]

Alternatively, you can right-click on the solution or an individual project and select "Manage NuGet Packages..." to do it through the GUI. If you right-click on the solution you'll be able to install a package to multiple projects at once.


Edited by mgood - 21-Aug-2012 at 9:41pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down