Saturday, August 18, 2012

Creating a Bootable USB Drive to install Windows 8 RTM

Recently, while downloading and installing the latest bits of Windows 8 (RTM Evaluation Version), I had an issue creating a bootable USB drive for it, using the  Windows 7 USB DVD Download Tool. I got an error when the tool attempted to format the drive.


I found another tool called WinUSB, which was quick to download and run. The steps are straight forward for creating a bootable USB device.  Run the tool, select your USB device from the list, locate your source Win8 ISO file, and click on Make USB Bootable. You will loose any data on the drive, so make sure to backup whatever you have there.




Here’s a complete tutorial about the tool, so check it out. Happy WinRT coding !

Thursday, August 16, 2012

Visual Studio 2012, Blend, .NET 4.5 and Azure SDK Update !

As many of you already know, Microsoft has made available quite a few tools, updates, SDKs and services for creating the new generation of .NET apps, including Windows 8.

I’m not going to try to cover what is has been covered already on official blogs and sites, but let me emphasise that you need to get on-board if you want to stay on top of your game.


You can start with Visual Studio 2012 and the .NET Framework 4.5 by downloading it here. Make sue to read Jason Zander’s blog post about it, and also Scott Hanselman’s coverage on the subject and some of the new features.

Then, take a look at the news on Somasegar’s blog, and head to the download link to get the latest bits for Blend + SketchFlow. There’s a bit more info on BlendInsider if you want to stop by.

If you are still curious, don’t forget to check out the updated Windows Azure SDK for .NET, which will make it work with your brand new Visual Studio 2012 tool.

Last but not least, make sure you open an account and check all the goodies that come with the Team Foundation Service, presented with a brilliant clean and fluid modern interface to manage your projects.

Also, Windows 8 is now available for developers who want to try out Windows 8 Enterprise 90-day evaluation.

Don’t loose time, go ahead and grab the latest bits. Is all about next generation application development around !

devenv.exe - Entry Point Not Found

I recently downloaded Visual Studio 2012 RC to start playing with all the new goodies, templates and tools coming in the new version. I was able to install it and run it without issues the first time.

However, after I closed it and tried to re-open it (and I believe restarted the machine in between) I got the error “devenv.exe - Entry Point Not Found” and VS refused to run at all !


Awful error, no description, no clue. However it seems that the community already caught it and Microsoft was quick to release an update to fix the issue. Many people are having the problem when installing both Visual Studio 2012 and Office 2013, which was not my case.


The update seems to fix the problems for all reported cases, and it fixed it in my case. You can get the update here.

Wednesday, August 15, 2012

Implementing Logging with NLog

Logging is vital to any production application. The most obvious reason is when your application experiences some kind of issue, or worst, crashes on a production environment. Since you won’t have your debugging and development tools on a production machine (or at least, you shouldn’t), it is necessary to have logs that can tell you what the application was doing at the time it crashed.

Logging is as important as an efficient and structured way to handle exceptions. You need to make sure you are handling exceptions correctly and that you are logging, not only the exceptions when issues happen, but also a history of steps as your application moves through the user journey.

I have used a few different tools and frameworks for logging implementations like Microsoft’s Enterprise Library and log4net, although they might be overkill for a simple logging solution. You can also write your own logging classes, after all, the point is to generate a text file with app workflow information, debug information and issues/errors details, but why invent the wheel all over again, right?

That being said, I wanted to share a sample prototype on how to implementing logging functionality in your application with NLog, in a simple, quick, step by step fashion. So here we go.

First: you need to download and install the NLog package. The easiest way is to do it through NuGet. If you haven’t used NuGet, check out this blog post about the subject.


Second: Now that you have the package reference, you need to add an NLog configuration file. Just right click on your project, select Add New Item, and select the Empty NLog Configuration File.


Third: Since NLog requires the configuration file to be copied to the application folder, you need to make sure that the NLog.config file you just added is copied to the output app folder. Right click on the NLog.config file and select Properties. Then make sure that the Copy to Output Directory is set to Copy always.


Fourth: now that all the configuration and package settings are set, we can create a logger. By design, NLog creates a logger per class. This just means that every class in your project will have its own logger, but all of them will write to the file you want, which is generally a unique text file that you will specify later. The advantage is that NLog will identify the class automatically, making it easier for you to identity application workflow steps and clearer log information. To create a logger you will use NLog LogManager.

You can specify the name of the logger as follows:

Alternatively, you can let NLog to name the logger automatically based on the class name:

Fifth: NLog has six different log levels:

  • Trace - very detailed logs, which may include high-volume information such as protocol payloads. This log level is typically only enabled during development.
  • Debug - debugging information, less detailed than trace, typically not enabled in production environment.
  • Info - information messages, which are normally enabled in production environment.
  • Warn - warning messages, typically for non-critical issues, which can be recovered or which are temporary failures.
  • Error - error messages.
  • Fatal - very serious errors.

So, now you can simply create a method and log some messages. Here’s an example on how to do it:

Sixth: Now that we have learned how to emit log messages, we need to configure the logging output on the NLog configuration file. you need to define the target file and the rules to have a basic configuration file setup. Here’s what your NLog.config file should look like:

And you are done. Now you have your app logging messages at different log levels, for any class you want on your application. This are screenshots from the sample app:




Make sure to check out NLog’s documentation for more advanced topics and different ways to use the loggers and do advanced configuration. Also if you don;t fancy using NuGet for some reason, you can download NLog bits directly from their site here.

Hopefully this will help you to get started quickly and easily. It certainly helped me out and is a perfect fit for a quick application logging implementation. You can download the sample application code from my Github repo here.

Scaling Yourself Up: No more Bookmarks


A couple of days ago I was having a look at the SXSW Panel Picker, to see what sessions are being proposed and voted for the upcoming conference. There are several colleagues from R/GA proposing, among some of them Brad Frost, Will Turnage and Phil Hawksworth.

I also had a look at Scott Hanselman proposal, which has a video of a previous presentation he did. On the session, he discusses ways to improve your productivity and how to scale yourself. Hanselman’s talks are often really good. He is a great speaker and a great developer, and he gets straight to the point.

At some point he talks about how bookmarks are not that effective. This touch a nerve for me, since I have been having this problem for many years. I tend to bookmark a lot of articles and references hoping that I’ll be able to read them later. With time I have gathered so many sets of bookmarks across my devices, from work, home, travel, etc. The reality is that I rarely read the bookmarks I have created. I have found repeated bookmarks, broken links and so many of them are not relevant any more after months or even weeks. I have tried to use readers, feeds, and many other approaches but I find myself getting lost between the sea of bookmarks when I’m out of context.

Well, I decided to follow Hanselman’s advise and completely stop using bookmarks. Instead, I have created an account on Instapaper, and installed Chrome’s extension to send the articles directly to my Kindle. Then I went through all my book marks and did a hardcore clean up, deleting anything that was not relevant or easy to find just by searching the Internet. I added only the relevant articles that I felt were important enough to my Instapaper list, and then I compiled the list of cool sites, companies, technologies and Online content sources that I feel are a daily basis reference. Those will go to the blog for sure and to my favourites bar, which now will always be visible, easy to find and condensed.

I truly believe that we need to try hard to become more productive and to help ourselves to scale up and down, with relevant sources of information and learn to ignore the information that is not important.

I hope to keep posting more about productivity tools, experiences, success cases and failed attempts, and hopefully you will benefit from it.

Tuesday, August 14, 2012

Allow GIT into Your Life !











Have you started to work with GIT already? Are you making GIT part of your daily programming life? Do you know how to clone a repo, add files, make a commit and push your changes using the console? Maybe through a visual GIT interface?

If the answer is yes, then you are already on track and probably know far more than myself regarding GIT. However, if your answer is no, then you might get some useful information if you keep reading.

I have used a few source control tools in my career. I have used Team Foundation Server (TFS) for .NET projects, which is quite robust and powerful, although big and somewhat difficult to set up and maintain. I have also used SVN, mainly with TortouiseSVN, which is quite common in open source and flash projects.

But we all know that things are moving towards GIT and similar distributed source control systems. I know that sometimes it would be really hard or even impossible for you to convince your colleagues or your tech directors to move towards newer source control systems. IT will always argue against it, especially if they already have a big centralized source control system in place.

No matter what is your situation, you should at least use GIT for your personal projects. You should check other distributed systems, like Mercurial (I’m doing it right now)  There’s nothing better than to share code, to provide and share knowledge, samples and experiences. I use to blog and share small bits of code, but it will always be better if you can actually share a full project, that people can compile and run. Additionally, if you commit yourself to maintain your prototypes, ideas, samples and such source controlled, you will get a lot of benefits !

So, I set myself up to start committing my prototypes and samples to Github so I can share them easily and post the links on my blog. I’m a Windows user, so I’m not used to typing commands in an ugly, unfriendly black screen. Add to that that I haven’t had to deal much with SSH and such, so getting started in my context is a bit hard and out of my comfort zone (which is actually quite good).

There are tons of useful blogs, tutorials, articles and guidelines about how to set up and start using GIT. However, it took me a bit of time and trial and error to get my stuff running, so let me share with you the info that actually got me up and running, hopefully it will help you too.

Install a GIT Tool: First, you need to install some kind of GIT utility. I chose msysgit for Windows, which apparently is the one people are pushing for.

Create your SSH key: you need to create your SSH key on your machine. You will add this key later to your remote GIT server account.

Create your Github account: well, actually is just creating your remote GIT server account, it might be a private company or client server, or your own server, although Github is by far the most popular GIT server, and is free !

Add your SSH key to your Git server account: once you have everything ready, you need to make sure to add the SSH key you generated, to your remote server account, so you can actually push your local changes to the server.

Check out the following links to get some help and guidance:

Hope it helps you out ! Make sure to check my stuff on Github here.

Monday, August 13, 2012

Spawning Windows On-Screen Keyboard (OSK) in WPF

During a recent project, I needed to be able to fire up the Windows 7 On-Screen Keyboard (OSK) utility from my application, which runs in kiosk mode. The application works mostly through touch gestures, but on certain steps users are required to enter text.

For starters, the straight forward way to do this is to simply start the external application process in the following way: If you need to run an external tool from a simple program, you can just add that calling line in your main program method:

Now, in this case, the main Kiosk application had a dependency with legacy unmanaged code, which required the app to target x86 processors (32-bit platforms). This is generally not an issue since Windows is able to run 32-bit apps on either 32-bit or 64-bit platforms.
The problem I had was that I could not spawn a 64-bit external app from a 32-bit application directly. Whenever I tried to fire up the OSK from my app I got an error saying that the OSK could not be launched.


The problem arises because Windows 64-bit has two versions of the OSK utility, one for 32-bit and one for 64-bit. My app, targeting a 32-bit platform was making the call, but since it was running on a 64-bit machine, Windows was handling the calling event and routing it to the 64-bit version of the OSK, which causes the error.

Since I could not switch the main app to target any CPU (both 32-bit and 64-bit platforms), I needed a work around to be able to run the OSK from my app. It turns out to be easier than I thought.

You need to create a secondary .net app targeting any CPU platform which is the one in charge of firing up the OSK. You can do this by creating a simple console application with the code I put above, but you will get the black console app screen when it runs, which is not ideal. Instead, you can create a simple Windows Forms application and take out the forms and just leave the main program with the Main() method. As you can see, the code to fire the OSK will be exactly the same, but you won’t see any black screen popping up.


Once you have the secondary app in place (make sure it works by running it a couple of times), just copy the executable to wherever your main app needs it. Then you can create a static utility class in your main app with a couple of methods to fire up and close the OSK.

Here’s the complete code to do so: Notice that the code is able to close the OSK process if it is already running without issues. It’s just firing up the OSK app that needs to use the secondary app. You just need to make sure that the OSK is not running before trying to fire it up and before attempting to close it. Remember to change the “YourKeyboardManagerAppPath” for the actual path where your keyboard utility app lives.

The nice thing about this workaround is that it effectively shows you how to fire third party apps from your main app, and how to use a secondary application as a bridge to fire up other apps if you have any problems doing so from your main app.


You can find a sample app setup with the complete code here.

Tuesday, August 7, 2012

Windows Developers have a New Home

Just a quick note about the new Windows Phone Dev Center site. The new site replaces the old App Hub site, which was somewhat confusing.

The goal of the new site is to make the submission process faster, and make it easier for developers to manage their account and track app’s progress. One nice feature is that developers can now set app prices per market.

Go ahead and check it out. Publishing and tracking your apps is just getting easier and faster !

Getting Started with NuGet

If you haven't heard about NuGet you are missing a lot of fun and a good productivity boost. NuGet is a Visual Studio extension that makes it easy to install and update third-party libraries and tools, that you can use in your projects when working with Visual Studio.

You can easily install it from their website. Alternatively, just click this link to download the installer. The new version, 2.0, was just released, and there are new goodies to take advantage of. The installation is straight forward and it will install the package manager extension on all the Visual Studio versions you have on your machine.

The beauty of NuGet is that it allows you to easily find and install popular, industry proven third party libraries and tools, but also publish your own packages to share with others. This is probably the best way to expose your own libraries and tools to other developers in a save and easy way.

To install a package, simply right click on your project references solution folder, and click on "Manage NuGet Packages".

The NuGet dialog will open and you will be able to browse and search packages, and apply handy filters to narrow down your search. Once you find the package you want, just click the install button and NuGet will take care of the rest.

Once the package is installed, you will see a green check mark next to it, and once you close the dialog, you will see the corresponding references and files added to your project, plus a "packages.config" file with the settings for the isntalled package.

That's it, you can just use the library you just installed right away.

Here is an overview of NuGet functionality, and here is more about the different ways to install and configure packages. Make sure to check the rest of the documentation to make the most out of it.

Hope it helps!

Sunday, August 5, 2012

Prepare for BUILD 2012


It is official, Microsoft is going to have its BUILD conference for the second time. This year though, it is going to be the real thing. The conference will happen almost at the same time when Windows 8 is going to reach the market.

We can expect to see the new Windows 8 eco-system at its full extend. Windows 8 computers and ultrabooks, WinRT slates and tablets running both on Intel and ARM processors, the new version and hardware for Windows Phone 8, and the interconnectivity with the Xbox entertainment hub, bigger than ever.

Registration opens on August 8th, so be ready to get in as soon as you can. This year’s BUILD will be held at the Microsoft Campus, in Redmond, Washington, so we can expect to be really close to the place where it all started.

Hopefully I’ll see you there, it time and work allows !

Solving Lumia 800 MMS Issues


Recently I was having issues to download MMS content on my Lumia 800. For some reason, whenever I received a text message containing media content I got the message just saying “Get Media Content”. However, every time I clicked on the link, it came back again after a couple of seconds without actually downloading the content.

After spending some time looking around on the Internet, I realized that this was a common issue people were having with their Windows Phone Lumia phones. Unfortunately it seems that the causes vary, so this solution might not work for you. I even found messages in O2 forums saying that you might need to change your SIM card !

The way I solved the issue was to simply download the Nokia Network Setup application. Once you download just let it find your network and set it up for you (should be automatic). That’s it. After that, I was able to receive and send MMS messages without issues.


One thing to notice, is that if you try to download the app from the web, it might be that you won’t be able to find the app on the Windows Marketplace. However, if you hit the link from your phone, you should be able to find it and download it without issues.

Hope it helps you and saves you time !