Quick work around for unresolved Xamarin components in Visual Studio

Have you ever had an unresolved component when  using the Xamarin plugin win Visual Studio?  You add a component from the Xamarin Component Store and after you installed it, it comes up as unresolved.

There is a path limitation that causes this error.  The components come packaged in a zip file with files inside folders.  When this length of the file paths in the zip file are factored in with the path length of your project, it can exceed Windows limits when the component is being added.

This only seems to be a factor when the component is being added.  Once the component has been added to the project, the path length is well within what Windows allows.  It also appears to be a Windows only issue, Xamarin Studio on OS X does not have this issue.

The way around this is to have your project on a shorter path.  There are a couple of ways of doing this.  The obvious way is to move your solution to a shorter path.  That’s annoying, especially if your code is already mapped a source control system that is expecting the files to be in the original path.

Another way around it is to make the path shorter via a directory junction. A directory junction is like a symbolic link, but is easier to get rid of when you are done with it.  You create a link with a shorter path to the original path and then reopen the solution using the shorter path.  You add the component, it will install cleanly now because the path length is no longer an issue.

Your code is still in the original location.  You didn’t move it, you just created an alias to that location and that aliased location looks and feels like a real path.  Once you have added the component, you can either leave the link or remove it.

You can add the link from the command, or you can install a shell extension and do it from Windows Explorer.  I’m a command line kind of guy so I prefer to do it that way with the mklink command.

Open up a command prompt shell with admin access (Run as Administrator).  Once you have an admin shell, use the following syntax:

mklink /j new-path original-path

For example, to create a shorter path c:\source\xamarin\myapp and have the new path named c:\x, do the following

mklink /j c:\x c:\source\xamarin\myapp

Now you can open your solution from the c:\x folder.

To get rid of a directory junction, just use the rmdir (rd) command.  To get rid of c:\x, you would execute the following:

rd x

That removes the directory junction, but does not touch the original location.

Looking back on Xamarin Evolve 2014

Xamarin’s Evolve 2014 conference was a great experience.  I attended it last week in Atlanta and while you see a lot of the cool new features from the live stream, the personal interactions made attending much more valuable.

Xamarin is much more focused on the enterprise customer.  They have picked up a bunch of new partners (Microsoft, IBM, etc) and companies like Amazon are focusing on Xamarin developers.  The 3rd party component vendors are coming out with component packs for Xamarin.Forms.  If your app needs a charting control, you have a wide range of commercial products to choose from now.

Xamarin.Forms has become a huge hit with developers.  Many of the training and conference sessions were focused on Xamarin.Forms.  If you are looking at Cordova for cross-platform projects, you should take a closer look at Xamarin.Forms.

A big reason to attend conferences like Evolve is to meet and share experiences with other developers and Xamarin staff.  Xamarin does a  really good job of having their people mingle with the users. Many of them were Xamarin users before becoming hired so they have a good understanding of what it’s like to use their software.

Keynote Highlights

Xamarin Android Player

During the keynote, Miguel de Icaza launched the Google Android Emulator.   While it was loading, he went on a long and funny rant about how it was.   At the end of the rant, he presented the Xamarin Android Player, their own emulator that uses hardware virtualization to run as fast (or faster) as an actual Android device.

Xamarin Android Player on OS X
Xamarin Android Player on OS X

The Android Player is similar to the Genymotion Player, and on Windows they both use Oracle’s VirtualBox virtualization product to host the Android images.  If you have used Genymotion, then this will feel familiar.  While everyone uses the personal license for Genymotion, it does require a paid license for commercial use. The Android Player will be free to Xamarin customers.

Android Player is a developer preview release and only has a couple of Android images currently available: Nexus 4 with KitKat and Nexus 5 with Jellybean.  It’s not clear on how you would add Google Play support, that is not in the downloadable images.  If you do anything

James Montemagno and Nat Friedman with Xamarin Insights

Introduced Xamarin.Insights, which provide real-time monitoring for Xamarin Apps. You can record every crash that happens and access that data from an online dashboard.  Users can opt in to share their contact information.  This gives you the ability to contact users to let them know when a bug that affected them has been fixed. From their blog:

You can add Insights into your application with just a single line of code. Insights will gather and report any uncaught native or managed exceptions. In addition, you will be able to track both past and active sessions, with full access to device statistics such as operating system and screen resolution. If you want a deeper level of control, you can simply “report” any caught exception, along with any additional data that will help you diagnose the issue, using Insights’ simple API.

Xamarin Profiler

Also in beta is the new Xamarin Profiler for iOS and Android.  The Xamarin Profiler will track memory and performance.  It will show you where in the code your application is spending the most amount of time and how much memory is being used over time.  The profiler will work with both Xamarin Studio and with Visual Studio.  This makes for a nice addition to the developers toolkit.

Xamarin Sketches
Xamarin CTO Miguel de Icaza using Sketches

Now you have the ability to play with the code in real time with Xamarin Sketches.  You can write code and see it execute as you write it.  It’s a handy way to test some snippets of code without having to go through the entire build cycle.  It’s kind of like LINQPad for, but works with OS X, iOS, and Android UI elements.


Based on the Calabash technology that is in Xamarin Test Cloud, we can now unit the UI with Xamarin.UITest,  You can write up test scripts in C# to simulate the user pressing buttons and entering text into the application.  UITest provides a REPL interface to allow you to interactively query the UI. This is useful for determining the name of the controls to reference in your scripts.

You can run the scripts locally and deploy them to test cloud.  UITest with Nunit allows the developer to set up unit tests for the UI and for the code behind the UI.

Xamarin Insights
Xamarin CTO Miguel de Icaza demoing the new profile

We now have the ability to add real time monitoring of our apps via Xamarin Insights.  You can record every crash that happens and access that data from an online dashboard.  Users can opt in to share their contact information.  That gives you the ability to contact users to let them know when a bug that affected them has been fixed.

And we also learned the proper pronunciation of “PCL” and “nuget”, courtesy of Miguel de Icaza:

It's pronounced as Pickles and Newjay
Xamarin CTO Miguel de Icaza during the Evolve Keynote

And then they added Xamarin support to the Multilingual App Toolkit

As of 6am EDT today, Microsoft’s Multilingual App Toolkit officially supports Xamarin for making it easy to manage language translations in mobile apps. Originally designed for Windows Store apps, the Multilingual App Toolkit (which I’m just going to call MAT) allows you to add new language resources and generate RESX files to compile into your app. It uses the XLIFF format for storing the translated resources and can import, export, and even machine translate your native text into other languages.

XLIFF stands for Xml Language Interchange File Format and is an industry standard file format that language translation companies can use to translate your text. XLIFF has some rudimentary workflow features that you track when a new text string has been added, or translated, or approved.

Prior to version 4, MAT only knew how to generate RESX files. That’s fine for Windows apps, but Android and iOS have their own formats. Android uses XML files in the folders for each language or local. The format is similar to the RESX format. For iOS, they store the string resources in text files, as key value pairs.

Last fall, I played around with that version and used T4 templates to render Android and iOS native resource files from the Windows RESX files. The MAT team decided to add that capability into MAT and improve on it. You can now add MAT support directly to Xamarin.Android and Xamarin.iOS projects. If you enable MAT support for Android, you can right on an Android project and add new languages to the project. They will be XLIFF files and will generate Android strings.xml files for each language.

Microsoft’s Cameron Lerum has been working on MAT and has brought it with him to Xamarin’s Evolve conference. I’ve had early access to beta builds of MAT 4 and it works much better than my mess of T4 scripts.

Microsoft’s Cameron Lerum demoing the Multilingual App Toolkit with Xamarin.iOS for Xamarin CTO Miguel de Icaza

The latest thing from Xamarin has been Xamarin.Forms, which allows you to write common UI code for Android, iOS, and Windows Phone. MAT v4 works just fine with it. Put your string resources in a RESX file and put that file in a shared library. Then you can access the compiled resource strings from both the code behind and in the XAML markup. You’ll need to add an IMarkupExtension to your project, but that will give you databinding to the localized string resources.

To find out more about the new version of the Multilingual App Toolkit, Cameron just posted an article on it on the MAT blog.  If you are attending the Xamarin Evolve conference this week, look for Cameron or myself and we can demo the new version.  If you are in Atlanta on this Saturday, the 11th, I will be doing a presentation at the Atlanta Code Camp that will feature how to use MAT to add localization support to native mobile apps.

Booked my flight for the MVP Summit in November

I finally got around to booking my flights to the MVP Summit in November. Getting a rental car this time, one of my co-workers will be the same flight and we can skip the taxi/shuttle/uber rides and do possibly see a little more of Seattle this time around.

Just got a nice bump in speed from Verizon FiOS

This morning I received an email from Verizon FiOS informing me that my upload speeds are now as fast as my download speeds.  I currently have the 50 Mbps download, 25 Mbps upload package.  I just checked with Ookla’s speedtest.net and my current speed is now 58/63.

Current Internet speed from my home
Current Internet speed from my home

For once, my upload speed is actually faster than the download speed.  One thing about FiOS, my connection speeds are almost always higher than what I am rated for.  I was a loyal Time Warner customer for years, but my upload speed was awful and the download/upload speeds approached, but never reached the speeds that I was paying for.

My Hallway Conversations interview is out

Hallway Conversations Podcast
Hallway Conversations Podcast

A couple of weeks ago I was interviewed for the Hallway Conversations podcast. That interview is now on their site and can be downloaded by your favorite podcast app. I talked with Phil Japikse, Stephen Bohlen, and Lee Brandt. I had met Lee a few years back, when he did a presentation for TVUG about using Kendo UI. We talked about the business case for using Xamarin for developing native mobile applications.

We had a good conversation about the merits for using Xamarin and who the target audience is for those tools. I talked about how and why I ended up using Xamarin for our first native app and what hurdles I had to overcome to get that app done. And we talked about the costs of the Xamarin product and how that really wasn’t a factor in why our company decided to go that route.

I had a lot of fun doing the podcast.  If you are considering using Xamarin to write native apps for Android and iOS, it’s worth listening to this podcast episode and an earlier one with Xamarin’s Jon Dick,

Using Powershell to concatenate files and strip off the headers

We had a request from a client to merge some files for an import process that we have.  As part of one of our applications, we can import delimited (comma, tab, etc)  ASCII files.   The client was generating the files from 5 different processes.  Each exported file has a single line header row, and the files were from OS X.  That meant that the files were Unicode encoded and ended each line with only a carriage return.

Our import process can only handle a single ASCII file with DOS style line endings (carriage return + line feed).  It’s a legacy system and it can’t be touched.  What we can do to concatenate the multiple files into a single file and strip out the header rows for every file after the first one.  And change the encoding to ASCII and use the CR+LF combination that DOS loves so much.

I’ve been doing a lot of Powershell lately, so it made sense with me to continue with that Swiss Army knife of scripting languages.  I ended up with the following script:

    [String] $Pattern, # input pattern to match, including path. Example: c:\export\*.txt
    [String] $Destination # Destination file to write

begin {
    $FileCount = 0

    # Get all of the files that match the wildcard pattern

    Get-ChildItem -path $Pattern | ForEach-Object {
        Write-Verbose "$FileCount $_.FullName"

        if ($FileCount -eq 0) {
            # For the file, just write it out as ASCII
            Get-Content $_.FullName | out-file -FilePath $Destination -Encoding ascii
        else {
            # For each additional file, skip the header line and append as ASCII to the destination
            Get-Content $_.FullName | select -skip 1 | out-file -FilePath $Destination -Append -Encoding ascii


    Write-Verbose "$FileCount file(s) processed"

The first five lines take care of the parameter binding. This script only needed two parameters. $Pattern is the path to the input files, including wildcards. $Destination is the full path to the file to concatenate the source files into. The optional “-verbose” parameter is supporting for displaying some text as the files are being processed. This is a standard Powershell parameter, that’s why it’s not included in the parameter list for this command.

    Get-ChildItem -path $Pattern | ForEach-Object {

We are using Get-ChildItem to get all of the files that match $Pattern and then call ForEach-Object to iterate through that list.

        if ($FileCount -eq 0) {
            # For the file, just write it out as ASCII
            Get-Content $_.FullName | out-file -FilePath $Destination -Encoding ascii

For the first file, we just need to read it in and output it back out to the destination files. Powershell will handle the line endings and we will force it to ASCII. The $_ variable is a placeholder variable. When you are using a Foreach-Object loop, the $_ represents the current item of the loop. When you get use Get-ChildItem for a file or folder, .FileName is a property of the item or array of items being returned.

        else {
            # For each additional file, skip the header line and append as ASCII to the destination
            Get-Content $_.FullName | select -skip 1 | out-file -FilePath $Destination -Append -Encoding ascii

For each additional file, we read the file in, select every line after the first line, and finally append it as ASCII to the destination file.

The “Write-Verbose” lines will only execute when the -verbose parameter is used. So if that script had been saved as c:\scripts\convert-files.psi, you would execute it like this:

c:\scripts\convert-files.ps1 -pattern c:\export\*.csv -destination c:\import\all.csv

c:\scripts\convert-files.ps1 -pattern c:\export\*.csv -destination c:\import\all.csv -verbose

That would concatenate all files that end with “.csv” in the c:\export folder and write a single file named c:\import\all.csv. If you add the “-verbose” parameter, you will see the names of the files as they are being processed.

Comcast did WHAT in Houston? You are now a public hotspot.

Yesterday, Comcast flicked the switch that turns the home routers for 50,000 of their Houston subscribers into public Wi-Fi hotspots. It’s been covered in a few newspaper articles, I came across it on this SeatlePI article and this followup by Dwight Silverman.  Dwight writes for the Houston Chronicle, but I saw the syndicated copy on the SeattePI site.

If you live in Houston and have a XFinity Router, then you may already be a public Wi-Fi hotspot.  The router serves up the public Wi-Fi access on a separate wireless network from your home network.  But it’s using your bandwidth and the possibly the same IP address.

If you do a search of Wi-Fi networks and you see one or more named “xfinitywifi”, then your or your neighbor is now a public hotspot.  This is an opt-out policy.  Unless you request not to be a public hotspot, Comcast is going to enable it on your router.  Comcast had sent out letters to their customers, but how many of them read those letters?

The idea sounds good on the surface.  If you are a Comcast customer, you will have Wi-Fi access whenever you are close to another Comcast customer.  You would be able to connect your tablet or laptop in more places.

One problem with this is that you are sharing the bandwidth available to that home subscriber.  Comcast is making more bandwidth available to the home, but they can’t create more Wi-Fi bandwidth.  You can only carry so much network traffic over Wi-Fi.  If you live in busy neighborhood or close to a shopping area, other Comcast customers connected to your router could use enough bandwidth to make it difficult for you to connect to your own router.  Comcast can alleviate that with Quality Of Service (QOS) rules in the router, but that wouldn’t eliminate the problem.

Then you have the security issues.  Unless Comcast has modified the routers to get two outside IP addresses, anyone who connects to the public hotspot from your router will provide the same IP address to the rest of the world that you provide  This is the external IP address that shows up when you are connected to a website, not the internal IP address that your device thinks it has.    That means if someone was using BitTorrent to download and share copyrighted material like music or movies, it would be your IP address that would be tracked.

When Comcast gets the subpoena from the MPAA asking for the identity of the person using your IP address because that IP was sharing copies of “Frozen”, will Comcast be able to determine that the offending activity was done over the public hotspot as opposed to your internal network?  If they have the same IP address, then you are going to be facing the legal battle to prove your innocence.

If the public Wi-fi can be traced separated from your use of the same router, then Comcast has just made it easy for people to run Bittorrent sharing sites or perform other nefarious activity anonymously.  Just connect a Hotspot named “xfinitywifi”.  It can from your router or your neighbor’s.  It doesn’t matter, it’s not traceable back to you.  Comcast can block ports used by Bittorrent clients, but it will be hard for them to block everything.

You can opt out after the fact.  SeattlePI’s Dwight Silverman posted the following instructions here.

  • Log into your Comcast account page at customer.comcast.com.
  •  Click on Users & Preferences.  
  • Look for a heading on the page for “Service Address.” Below your address, click the link that reads “Manage Xfinity WiFi.”  
  • Click the button for “Disable Xfinity Wifi Home Hotspot.”  
  • Click Save.

With the Comcast/Time Warner Cable merger currently in FCC review, this could affect more than Comcast customers,  If you are a Time Warner Cable customer, it’s possible that after the merger that public Wi-Fi program could be rolled out to TWC customers.  This is just one of those ideas that sounds good on people, but make me uneasy when they are actually implemented.

Been reading “iOS Development with Xamarin Cookbook”

iOS Development with Xamarin Cookbook
iOS Development with Xamarin Cookbook

A new Xamarin iOS book has just come out and if you’re programming for the iPhone on the Xamarin platform you will want it on your bookshelf.  It’s titled “iOS Development with Xamarin Cookbook” and is written by Xamarin MVP Dimitris Tavlikos.

This book will take you from the first steps in writing and compiling an iOS application with Xamarin to working with advanced topics like writing multi-touch gestures and working with iCloud.  The intended audience for this book are .NET developers new to iOS development and Objective-C developers who want to be able to use the Xamarin tools.

This is not a cross-platform guide.  While a few topics have corresponding features with Xamarin.Android, this is an iOS only book.  For example, chapter 12, “Multitasking”, covers the iOS specific APIs for running code in the background and how to respond to events raised by the background code.

The advantage of writing a guide for one platform is that Dimitris can go deep on specific features and APIs.  Each chapter has a set of “recipes” that explain how to do a task.  Each recipe is independent from the others.  You don’t have to build the first four recipes in a chapter in order to try out the code for the fifth.

Each recipe follows a pattern.

  1. Recipe Name: First Dimitris describes what the recipe will do
  2. Getting Ready:  What has to be done before the recipe code is written.
  3. How to do it:  A series of steps that describe the code to write
  4. How it works: An in-depth description of what that code does
  5. There’s more: Addition information about this feature
  6. See Also: A list of other recipes that are related to this one

For me, the book was worth it just for chapter 14, Deploying.  I don’t have to submit apps to App Store that often, it’s useful to have all of the steps required, all in one spot.

This one is for your grandparents (aka “I’m calling you from Windows and you a have virus”

Only you can save Grampy and Oma
Only you can save Grampy and Oma

OK people, this one is for your parents and your grandparents.  There is an annoying scam that has been going around where they get called from someone claiming to be from Windows and the weasels have detected a virus on their PC.  And then the weasels extort hundreds of dollars from the nice people who gave you money for every report card.  And you can protect your people. You are their only hope.

The weasels employ some cheap tricks to convince you that your machine has a virus and then get you to install a remote access app to let them hijack your PC.  With control over your PC, they can install pretty much anything they want.  Then you find out that you need to pay them lots of money to get control of your PC back.  Or they’ll lock it up so you can’t use it all.

This is what you need tell Grandma.  When the weasel calls from Windows, just hang up.  Don’t say anything once you hear them say they are from Windows or are from “Tech Support”, just hang up. They may call right back, or perhaps the next day.  Just hang up.

This scam has been going around for a few years and it’s classic social engineering.  They will walk you through launching the Windows event viewer and have you scroll through the list until you see an error message.  You’ll always see an error message, something is always complaining about something under the hood.  It’s more or less business as usual in Windows.

There's always an error, you can ignore most of them
There’s always an error, you can ignore most of them

But the weasel is going to tell you that it’s a virus and they will fix it for you.  he tell you that he needs to access your PC to verify what the problem is. He’ll have you run “a diagnostic tool”, that’s how the weasels install their malware.  Once their software is installed, they basically own the machine.  If you don’t pay up, that machine is basically under their control.

This scam has been going around for a few years.  Why?  Because it works.  Enough people are fooled to where this can make some money to people who are clearly deficient in the moral compass department.

This is on you to be the first line of defense for your family and friends.  If Mom and Dad (or Grandma and Pop-pop) have a PC and are not IT skilled, then make sure their important stuff is backed up somehow.

Here’s  a short list that easy to do:

  1. Have a copy of all of their email accounts and passwords.  If their machine gets compromised, you should be able to go online and change all of their passwords for them.
  2. Ditto for their Facebook and other social media accounts.
  3. Make sure that if they do any online banking, they use unique passwords for each account.  And have them write that stuff down.  They may not want you to have the keys to your future inheritance, but you need to be able to help them lock down the access to those account.
  4. Write down the product keys for anything that needs to be reinstalled.  That includes Windows.  There are free tools like Belarc Advisor or Magic Jelly Bean that will look this information for you.  If you need to reinstall Windows, this will savea  lot of time.
  5. The sky is the limit for backups, at the very least get portable hard drive and just backup their important files on a regular basis.  I would use two drives and swap them out.  Go on the assumption that the drives will fail after year.  It’s OK, Staples will have them on sale again.   In addition to protecting their files from someone locking up their PC, you get the backup protection in case the hard drive goes on the PC.

The first four steps, you just need to once and update when their accounts are changed.  The backup you just have to get them in the habit of doing.  Or you just do it for them.

Just remember the cardinal rule: hang up the phone.  If Grandpa doesn’t want to hang up in the case that it’s valid call, then let the call go to the answering machine.  If it’s a real call, they’ll leave a message and a call back number.  A weasel is not going to leave a number where you can call them back.

A great suggestion came in after I originally posted this.  When the weasels call, tell them that you work for Microsoft.  They’ll hang up and not call you again.  Different weasels will call, but not ones that called you before.

Photo from SalFalko’s photostream on Flickr, used under CC license.

A work in progress

%d bloggers like this: