Nico's digital footprint

I grew up in the nineties, that makes me awesome by default

Community day 2013

by Nico

Yesterday was the day for Community day 2013, already the seventh edition. A bunch of user groups working together to create a great agenda of presentations by community, for community.

This seventh edition was in my opinion the best one so far, the quality of the talks I followed was incredible and I’ve learned quite a lot.

I also did my own talk on SignalR and Windows Phone 8. Here you can find my slidedeck.

 

And my demos can be found here (this includes the chat demo, the leap motion demo and the Photobeamer clone.

As mentioned during my talk, the photobeamer clone is something I did a blogpost on a while back, for those interested the post can be found here

I had a blast at Community day 2013 and I’m already looking forward to the next edition!


Tags:

.Net | Community | LeapMotion | WP8 | Talk | signalr | XAML

Run your WP8 app on two emulators simultaneously

by Nico

I’m currently working on a Windows Phone 8 project that requires two devices. Those devices talk to each other through a SignalR service. Thanks to Hyper-V I’m able to test/debug this project on two instances of the Windows Phone 8 emulator (I usually pick the WVGA and WVGA 512MB versions). What I used to do is deploy the XAP to one emulator and debug it on the second. I need to do this every time I change the app, I got bored of doing this manually so it was about time to get this automated.

Since Visual Studio 2012 builds the app everytime its codebase changes I can use the post-build script to do this, after all the app should only install itself on both emulators when it’s changed (I did spent time looking for a solution to let the script run every time I hit the debug button but it looks like there’s no way to do this in VS2012).

The point of the post-build script is to fire up the emulator when needed, deploy the app and run it. Visual Studio 2012 debug will fire up the second emulator, deploy the app there and launch it with debug, meaning that only one emulator will have a debugger attached.

Choosing the emulator for the script

Microsoft has provided a command line tool for deploying xap files, both onto a device and onto the emulators. Before we can start using it we’ll need to know the correct index of the emulator that we want the script to use. Copy-paste this script into a textfile and save as a .bat file, double click it and you should see a list of all available emulators on your machine (provided that you have the Windows Phone 8 SDK installed of course).

Code Snippet
  1. cd "%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\XAP Deployment"
  2. XapDeployCmd.exe /EnumerateDevices
  3. pause

XapDeployCmd.exe is the commandline tool for everything related to XAP deployments. More information on the tool can be found on MSDN

Choose the emulator of your choose from the list and remember its index.

Building the script

Time to start building the script. In your Windows Phone 8 project, go to the project properties to the Build Events tab. In the Post-build event command line box enter this script.

Code Snippet
  1. cd %ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\XAP Deployment
  2. XapDeployCmd.exe /installlaunch $(TargetDir)$(ProjectName)_$(ConfigurationName)_$(PlatformName).xap /targetdevice:1

The first line of the script navigates the command line to the folder where the XapDeployCmd lives (this is the default install path, the tool comes with the WP8 SDK). The second line launches the tool and passes the necessary parameters. the installaunch parameter states that the app should install (or update) the app and launch it when finished. After the installaunch parameter we need to state the path to the xap file, by default (when using the debug configuration in VS2012) it’s in the bin/debug folder and is called something like MyWPApp_debug_anycpu.xap. To make the script easy to transfer over I’ve used variables instead of hardcoding the path and the xap name. Here’s a quick rundown.

Variable Meaning
$(TargetDir) the full path to the outputdirectory (for example: c:\users\nico\documents\Projects\MyWPApp\bin\debug\)

Keep in mind that the last “\” is always included when using this variable
$(ProjectName) The name of the project (didn’t see that one coming, did you? Glimlach) (for example: MyWPApp)
$(ConfigurationName) The used configuration, for example ”release” or “debug”
$(PlatformName) The selected CPU architecture, for example “AllCpu”, “ARM”, “x86”

With these powers variables combined we get the full path to the xap file. The last parameter specifies the to use emulator by passing in the index that we determined at the beginning of this post.

And that’s it. Rebuild your solution and watch the emulator start app, deploy and launch your app. Now every time that you change the code of the app and hit the debug button it will build and deploy to both emulators. One of the emulators should have those debug numbers on the side, making it easy to recognize which one has the debugger attached.

Conclusion

Using a very simple post-build script and the in the WP8 included XapDeployCmd tool it’s very easy to deploy an application to two devices simultaneously. This isn’t needed very often but when building something that connects users to each other (like a chat application or a multiplayer game) it can save you quite some hassle. Just make sure that your script uses another emulator version than Visual Studio 2012.

 


Tags:

.Net | Devices | WP7 | WP8 | msbuild

Error tracking with RayGun and free t-shirts!

by Nico

I received a mail from Mindscape stating that their product called Raygun was coming along nicely and if I was interested in trying it out and blogging my finding. I would receive a bunch of t-shirts to hand out during user group events. So here’s me, writing my findings of RayGun (which is actually a cool product) and hoping to receive free t-shirts, the things I do for community Glimlach

RayGun

So what is RayGun? RayGun plugs into your apps and sends errors to the server. You as the developer receive an email stating that a new error has been found.

What’s great here is that you can resolve the error here with one click, the second link will open the error details on the site and immediately change its status to Resolved.

If you view the error you get all the information that you expect from a service like Raygun. Information about the device that the error occurred on, the used resolution (always 800x480 for Windows Phone as that is the base resolution, all apps are upscaled from there but it still reports as 800x480) and of course the complete stacktrace.

You can even view RAW data in JSON format.

Code Snippet
  1. { "MachineName": "RM-821_eu_belgium_464", "Error": { "Data": [], "ClassName": "System.Exception", "Message": "Exception: raygun test", "StackTrace": [ { "LineNumber": 0, "ClassName": " at RayGunDemo.MainPage.ButtonBase_OnClick(Object sender, RoutedEventArgs e)" }, { "LineNumber": 0, "ClassName": " at System.Windows.Controls.Primitives.ButtonBase.OnClick()" }, { "LineNumber": 0, "ClassName": " at System.Windows.Controls.Button.OnClick()" }, { "LineNumber": 0, "ClassName": " at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)" }, { "LineNumber": 0, "ClassName": " at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)" }, { "LineNumber": 0, "ClassName": " at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)" } ] }, "Environment": { "ProcessorCount": 0, "OSVersion": "Win32NT 8.0.10211.0", "WindowBoundsWidth": 480, "WindowBoundsHeight": 800, "CurrentOrientation": "PortraitUp", "TotalPhysicalMemory": 0, "AvailablePhysicalMemory": 0, "TotalVirtualMemory": 0, "AvailableVirtualMemory": 0, "DiskSpaceFree": [], "DeviceName": "RM-821_eu_belgium_464", "UtcOffset": 0, "Locale": "Nederlands (België)" }, "Client": { "Name": "Raygun4Net", "Version": "Mindscape.Raygun4Net.WindowsPhone, Version=1.0.5.0, Culture=neutral, PublicKeyToken=null", "ClientUrl": "https://github.com/MindscapeHQ/raygun4net" } }

You can add comments to errors, assign people to them, all in all RayGun feels very complete. The mail arrived immediately after the error was thrown, shows up nicely on the dashboard, both the Windows Phone emulator and my Lumia 920 over 3G reported the error perfectly.

Implementing RayGun

Implementing RayGun in your app is very straigthforward, go to http://www.raygun.io and register for a trial account (pricing can be found here http://raygun.io/pricing). Once your account is registered you arrive at a page that tells you the steps to integrate RayGun with your app.

Nifty feature here is that your api key is integrated in the sample code that they give you, so it’s just copy/paste. It may sound stupid but I really liked that sense of detail.

First thing we need to do is add RayGun through NuGet.

Bit weird here is that a readme file pops open stating that for Windows Phone I need to Reference the "Mindscape.Raygun4Net.WindowsPhone.dll but NuGet is smart enough to reference the correct DLL depending on the platform that you’re developing for.

Second step is adding a property of the RayGunClient to App.xaml.cs and instantiating it with the api key.

Code Snippet
  1. public static RaygunClient RaygunClient { get; set; }
  2.  
  3. /// <summary>
  4. /// Constructor for the Application object.
  5. /// </summary>
  6. public App()
  7. {
  8.     RaygunClient = new RaygunClient("<your key here>");

And for the initial setup there’s one step left. In the Application_UnhandledException method add the actual call to the RayGun servers (line 4).

Code Snippet
  1. // Code to execute on Unhandled Exceptions
  2. private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
  3. {
  4.     RaygunClient.Send(e);
  5.  
  6.     if (Debugger.IsAttached)
  7.     {
  8.         // An unhandled exception has occurred; break into the debugger
  9.         Debugger.Break();
  10.     }
  11. }

And from now on, any unhandled exception is logged in RayGun and you’re notified immediately when they occur. Try it out by adding a button on your mainpage and set this as click event.

Code Snippet
  1. private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
  2. {
  3.     throw new Exception("raygun test");
  4. }

Since the RayGunClient in this example is a static property in App.xaml.cs you can reuse it anywhere in your project. You can even start creating completely custom errorlogs by passing in a RayGunMessage instance in the Send method.

Conclusion

RayGun works as advertised, no problem there at all. The dashboard looks great, is easy to navigate and shows all the necessary information. Crash reports arrive really fast and have nice little details like a one-click link to resolve an error. Small mistake in the readme file that opens when adding the NuGet package can be forgiven (who reads readme files anyway?)

Will it be a great success? I don’t know. There’s quite a lot of competition out there, services that offer the same stuff as Mindscape does with RayGun but often times they are either free or provide a limited free service for hobby developers. Personally, I feel that MindScape should include a free price plan as well, limited in such a way that it’s only suitable for hobby projects of course since everyone needs to make a living. But those hobby developers can create buzz around the product so that professionals will pick up on it as well.

By the way, this post only talks about the Windows Phone part of RayGun but it supports a wide array of platforms like ASP.net, JavaScript, PHP, Ruby on rails, Java and ColdFusion.

So all in all, great product, works as advertised! If you want a t-shirt come to the next MADN user group event after the summer break and hopefully we’ll have some to hand out!


Tags:

.Net | Community | XAML

  Log in

About the author

Hi,

My name is Nico, I’m an MVP Windows Platform Development living in Belgium.
I’m currently employed as a .NET consultant at RealDolmen, one of Belgium’s leading IT single source providers.

I'm also founding member and board member of the Belgian Metro App Developer Network, a user group focussed on Windows 8 and Windows Phone development. If you're in Belgium feel free to drop by if we're doing an event. http://www.madn.be

Since June 2012 I'm a proud member of Microsoft's Extended Experts Team Belgium. And in February 2013 I became a member of DZone's Most Valuable Bloggers family.

In 2013 I became a book author and wrote "Windows 8 app projects, XAML & C# edition".

In 2014 I received the MVP award for the very first time.

I hope to get feedback from my readers either through comments, mail (nico_vermeir@hotmail.com), twitter, facebook, …

 

mvp

 

mvp

 

 

MeetLogo

 

MVBLogo

mybook

 

Month List