Skip to main content

Posts

Showing posts from August, 2012

Windows 8 AppBar style not found.

The Windows 8 AppBar comes with a set of default icons embedded in a set of AppBarButtonStyles . These styles are available inside the StandardStyles xaml file inside the Common folder of your Windows 8 XAML project. The strange this was that when I tried to apply these styles to my AppBar buttons, Visual Studio complained that it couldn’t find the related resource: <Button Style="{StaticResource AddAppBarButtonStyle}" /> I spent way too much time before I discovered that for one reason or another the AppBarButtonStyles were commented out inside the StandardStyles.xaml. Doh! After uncommenting the styles I wanted to use, it worked perfectly.

Caliburn.Micro: Design time support

WPF and Caliburn.Micro are a powerful combination. You create a viewmodel and related view, name your controls appropriately  and all magic happens automatically. Controls are bound to the View Model’s properties and methods for you. The problem is that it is all happing at run time not at design time. So when you are developing inside Visual Studio or Expression Blend you aren’t able to see how the form will look like with bound data. Caliburn.Micro supports design-time binding out-of-the-box. How can we configure this? In the constructor of my ViewModel, I check if we are executing in design time: public class SampleViewModel : Screen { public SampleViewModel() { if (Execute.InDesignMode) LoadDesignData(); } } In this sample I populate my ViewModel with some sample data at design time. private void LoadDesignData() { this.Sessions.Add(new ProfilerSessionViewModel() { Id = Guid.NewGuid(), Duration = "30ms", Name = "Session 1", Started = Dat

Some random Azure news…

Windows Azure Training Kit Last week Microsoft released the August 2012 version of the Windows Azure Training Kit . The update of the Windows Azure Training Kit includes 41 hands-on labs and 35 presentations . Some of the updates in this version include: Added 7 presentations specifically designed for the Windows Azure DevCamps Added 4 presentations for Windows Azure SQL Database, SQL Federation, Reporting, and Data Sync Added presentation on Security & Identity Added presentation on Building Scalable, Global, and Highly Available Web Apps Several hands-on lab bug fixes Added the Windows Azure DevCamp 1-day event agenda Updated Windows Azure Foundation Training Workshop 3-day event agenda Azure Storage Explorer 5 Preview 1 I also noticed that a new version of the Azure Storage Explorer is available. Azure Storage Explorer is a useful GUI tool for inspecting and altering the data in your Windows Azure Storage storage projects including the l

Visual Studio 2012 RTM: Async tests are not found when using .NET Framework 4.0

For a project I created some async unit tests inside Visual Studio 2012 RC . [TestMethod] public async Task AsyncTest() { var result = await MyOperationAsync(); Assert.IsTrue(result); } Last week I took the opportunity to upgrade to the VS 2012 RTM version. But when I tried to run my async tests again, no tests were executed and the MsTest engine reported that no tests were found?! When I removed the async and await keywords, MsTest found my tests again… What has changed in Visual Studio that this no longer works? It took me some time to figure out the root cause. What happened? As the projects I wanted to test were .NET 4.0 projects, I decided to set the Unit Test project also to .NET 4.0. Of course in .NET 4.0, you don’t have async support out-of-the-box. So I installed the “Async targeting pack for Visual Studio 2012” . The "Async Targeting Pack for Visual Studio 2012" enables projects targeting .NET Framework 4.0 or Silverlight 5 to use the As

WinRT: The notification platform does not have the proper privileges to complete the request.

While trying to register my Windows 8 app for push notifications using PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync() , it always failed with the following error message: The notification platform does not have the proper privileges to complete the request. (Exception from HRESULT: 0x803E0208) Reading the exception information made me think that my app was missing some declarations in the app manifest, but the only one I needed was the internetClient capability and I couldn’t find another related declaration. In the end the MSDN forum brought the rescue. I was running in the simulator and it that case you don’t have the required privileges. Running from Local Machine solved the issue.

Caliburn Micro: configuring the Window dialog

Caliburn Micro offers you the WindowManager to display a dialog. You only have to specify the viewmodel and Caliburn will do the rest, it finds the corresponding usercontrol, embeds this usercontrol into a window, binds view and viewmodel together and shows the result to the user. var loginViewModel = new LoginViewModel();  WindowManager windowManager = new WindowManager(); SettingsViewModel vm=new SettingsViewModel(); windowManager.ShowDialog(vm); But what if you want to change the behavior or the look of this window? As Caliburn.Micro creates this window for you, you don’t have direct control over it. Therefore the WindowManager.ShowDialog method has an extra overload which allows you to specify a settings object (as a Dictionary<string,object>). How can we use this? An example… dynamic settings = new ExpandoObject(); settings.WindowStyle = WindowStyle.ToolWindow; settings.ShowInTaskbar = true; settings.Title = "This is a custom title";

Caliburn.Micro: Using a local resource as a proxy to your viewmodel

For a project we are doing we are using the ArcGis WPF components. As we want to use a MVVM architecture we try to use databind wherever possible(by using Caliburn.Micro). The problem is that one of the WPF components (the GpsLayer) inherits from DependencyObject, but the DependencyObject is not linked to a DataContext. Microsoft states that the DO should inherit the DataContext from the containing FrameworkElement, but that in fact doesn't happen. The only samples we found that worked were using the StaticResource approach: <Window.Resources> <local:MainViewModel x:Key="MainViewModel" /> </Window.Resources> <Grid DataContext="{StaticResource MainViewModel}"> <esri:Map Extent="-14268281.1311858,2195120.17402859,-7232639.54776086,7467160.93387503"> <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" /> <esri:GraphicsL

Remove Source Control Bindings

One of the annoying side effects of TFS (compared to Git) is that it adds a lot of extra files to manage the source control integration. This is not a problem as long as you don’t want to share your solution with someone else.  But the moment you zip your code and let them open up your solution, they get weird warnings from Visual Studio when they load the solution and projects. What we need is a simple way to strip out all the source control bindings before we distribute the code. And that’s exactly what Saveen Reddy did.  He created a tool called VSUnbindSourceControl( https://vsunbindscc.codeplex.com/ ) Usage: Copy your solution to a new directory (because the tool does modify files) Run this command: VSUnbindSourceControl.exe d:\myfolder Once the tool is finished, all the source control bindings have been removed from an SLN files and from any *proj files. Thanks Saveen!

Translating localized error messages

I talked about translating localized error messages before , but this time a colleague (thank you Martin!) found a similar tool: http://finderr.net/ “FindErr.NET solves the problem of almost nonexistent resources on the web for most software problems when they are sought for in their localized form - this is due to the fact that most problems are described in English. FindErr.NET helps software developers to diagnose problems sent by their international clients with less effort. After quickly finding the meaning of an error message, developers are able to quickly debug the problem or ask for help on internet forums. FindErr.NET assists IT professionals (such as IT Support personnel, system administrators or computer power users) to find information on a problem they encounter on a localized version of Windows (or a Windows installation with a language pack installed). After finding English equivalent of an error message, it is much easier to locate a solution on support

TFS gets one step closer to distributed source control…

Between all the news about the release of Visual Studio 2012 and Windows 8, you’ll almost forget that Microsoft has other products too. Last week Brian Harry announced Git-tf, a solution that enables you to work locally with a Git repo – edit, commit, revert, branch, merge, etc. and then “sync up” with a central TFS repository. In this way, you can have the best of both DVCS and TFS. The integration takes the form of a new command line tool called “Git-tf”. Git-tf works with a standard Git install and getting started is super easy. Just visit the download page and checkout Git-TF_Getting_Started.html. At the moment Git-tf won’t work with Team Foundation Service – it will only work with an on premises TFS server – either 2008, 2010 or 2012(but support for Team Foundation Service will be added soon).

Configuring AppFabric caching

For a project we are planning to scale out to a web farm solution. Therefore we started by configuring the AppFabric cache using the information found here: http://www.cshandler.com/2011/07/using-window-server-appfabric-for.html . However no success, when we tried to run the site we ended up with the following yellow screen of death: After further investigating the issue, we noticed a little bit more useful error message Could not load type "Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider” We had added the correct reference so why couldn’t  the application find that class? In the end we found out that some lines were missing inside the assemblies section of our web.config: <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <!-- other assemblies --> <add assembly="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKe

Community TFS Build Extensions: NUnit activity

For a customer I was replacing the MSTest activity inside the Build Process template by the NUnit activity from the Community TFS Build Extensions( http://tfsbuildextensions.codeplex.com/ ). After configuring the activity I saw inside the build log that the NUnit tests were running fine and that the results were published to Team Foundation Server. According to the documentation I should also see the results inside my build report: But when I opened my report no test information was available. What went wrong? When the the Build report is loaded, it tries to find the related test results from the TFS database. One of the filter criteria to find the correct tests are the build platform(e.g. Any CPU,x86,…) and flavor(e.g. Debug, Release,…).  This means that if you passed the wrong information to the NUnit activity, TFS will not be able to find the test results in the TFS database. And this was exactly what happened to me. I hardcoded the flavor inside the activity to “

Building mobile applications: the big question.

Everyone who is planning to build a mobile application has to answer the same question: ‘What approach should I take?’ I posted about this question before but while trying the Icenium beta I found the following interesting posts about this topic: What is a Hybrid Mobile App? Hybrid or Native? Inside these posts they talk about 3 possible answers to build mobile applications: Native apps are built for a specific platform with the platform SDK, tools and languages, typically provided by the platform vendor (e.g. xCode/Objective-C for iOS, Eclipse/Java for Android, Visual Studio/C# for Windows Phone). Mobile Web apps are server-side apps, built with any server-side technology (PHP, Node.js, ASP.NET) that render HTML that has been styled so that it renders well on a device form factor. Hybrid apps , like native apps, run on the device, and are written with web technologies (HTML5, CSS and JavaScript). Hybrid apps run inside a native container, and leverage the

IIS Manager Error: A specified logon session does not exist. It may already have been terminated.

Last week I was configuring a TFS 2012 server to support https. I installed a wildcard SSL certificate on our Windows 2008 Server trying to install a wildcard SSL cert.  I launched the Certificate Snap-in inside MMC and placed the SSL certificate into the local computer repository without problems. But when I opened the IIS manager to use this certificate, the problems started. I wanted to enable SSL for the TFS website, so I selected the web site and choose the Bindings option from the action menu. The site bindings window was loaded. I clicked Add… to add a new binding and choose https from the Type dropdown. But when I tried to select the certificate from the SSL certificate dropdown, I got the following error message: A specified logon session does not exist. It may already have been terminated. (Exception from HRESULT: 0x80070520) I could click OK but the binding didn’t work. On the IIS forums I found the following post mentioning two possible solutions:

Disable NuGet Package Restore

Enabling the NuGet  package restore feature is easy. Just right click on your solution inside Visual Studio and choose the 'Enable NuGet Package Restore' option. However what if you want to disable this again? I couldn’t find an option to do this, so let’s investigate all the changes that this option made. First it added a .nuget folder containing a nuget.targets file and nuget.exe. So we’ll start by removing this folder and all its content from your solution. Second it added an import to this target file to all your projects that are using NuGet packages. To remove this import right click on each project and choose unload project. Right click then on the csproj file and choose the Open with… option from the context menu. Choose the XML editor to edit the file. Browse the following line and remove it from the csproj file: <Import Project="$(SolutionDir)\.nuget\nuget.targets" /> We are not there yet. There is one other change that is done to your pro

WPF: Referring to a resource dictionary in another assembly

For a client I created a re-usable set of resource dictionary files. So I embedded them in a separate assembly that can be referenced in other WPF projects. But I always forget the correct syntax to refer to these resource files. So just as a reminder to myself: <ResourceDictionary Source="pack://application:,,,/YourSharedAssembly;component/Subfolder/YourSharedResourceFile.xaml"/>

GitHub: view commits that include images

One of the cool features in GitHub is the way it allows you to compare images. Image your designer created a first version of your new company logo and later he does some small changes. How can you easily detect what’s changed?  GitHub gives you four easy ways to view changes between image versions: 2-up , Swipe , Onion Skin , and Difference . Let’s have a look at how this works: Open your GitHub repository Go to Commits Click on the Commit that contains the image change. Now you see the different images next to each other. This is the default 2-up view which lets you get a quick glimpse of both images. In addition, if the image has changed size between versions, the actual dimension change will be displayed. (Hmm, I’m wondering what the designer has changed… ) Let’s click on Swipe to switch to another view. This lets you view portions of your image side by side. By dragging the swipe slider you can see the old version transform to

Web Deploy 3

Between all the announcements about the release of Visual Studio 2012, Windows 8, Windows Server 2012 and so on, I noticed one small announcement : the release of Web Deploy 3. Web Deploy 3.0 can be installed using these links x86 / x64 . More details on installation can be found in Installing & Configuring Web Deploy tutorial. Let’s have a look at some of the new features available in Web Deploy 3: Deployment & Migration to IIS8: migrate to IIS8 from IIS 6, IIS7 and IIS7.5. Publishing to Microsoft Azure Websites: deploy websites to Microsoft’s new Azure Websites offering. Incremental Database Publishing using Data Tier Application (DAC) framework: incremental data sync and SQL Azure download using SQL DACPAC framework. Automatic Backup:  allows server administrators to configure servers in such a way that each publish will automatically generate a backup and store it on server. If you need to roll back or go to a previous version, you will be able to do

NuGet: change build action value

For a client, I had to create a custom NuGet package. This packaged adds some custom content(images, scripts, icons,…) to an ASP.NET MVC project. Adding the content files was no problem, however I noticed that the BuildAction was incorrectly set. To solve this we need some Powershell magic. Create an install.ps1 file and add it to your NuGet package(More info here ). Inside the powershell file I added the following code: param($installPath, $toolsPath, $package, $project) $item = $project.ProjectItems | where-object {$_.Name -eq "ReleaseNotes.txt"} $item.Properties.Item("BuildAction").Value = [int]2 To find the correct enum value for BuildAction have a look here: http://msdn.microsoft.com/en-us/library/aa983962(VS.71).aspx Remark: Note that the search through the ProjectItems is not recursive. Subfolders are not scanned.

TFS: Do a check-in without triggering a continuous integration build

One of the new features in TFS 2010 is Gated checkin . In this case when you check-in some code, a build is triggered that will build the existing code, plus your check-in. Only when the build is successful, your check-in is submitted to source control.  In that case it makes no sense to trigger another build, as this will keeps triggering builds until eternity. To tell the build system to ignore the check-in operation, a check-in comment value “***NO_CI***” is specified to indicate "No Continuous Integration"meaning "please don't start a CI build because of this check in". You can perfectly use it for your own builds too. Place the following into the comment field: ***NO_CI*** and when you check-in TFS will not kick off a build.