Using InvokeCommandAction in Winodws 8.1 Universal Applications

This is just a PSA posting.

If you are making the jump from Windows 8 or Windows Phone 8 XAML development and are used to use the EventToCommand helper which comes along w/ the MVVM Light framework, things have changed and it is ok. In fact Laurent has a nice post on how to use the new built-in EventTriggerBehior rather than the EventToCommand helper.

However, there is two key pieces of information missing from his examples.
1) In order to get the Interaction.Behaviors namespace included you reference the Behaviors SDK inside your Windows 8.1 project
2) You will need to add reference to the correct namespaces in your xaml (see below)


Once you have done these 2 things you should be good to go.

Till next time,

Posted in Uncategorized | Leave a comment

Accessing Visual Studio Online from YOUR Azure Account – Now we can with this new PaaS offering

In case you missed Brian Harry’s announcement – we can now either link existing Visual Studio Online (VSO) instances OR we can create brand new VSO instances and control them through the Azure Portal. The problem before was that there had to be a 1:1 correspondence between VSO an a Microsoft Account. If you’re managing your own projects, that is likely not a problem. If however, you are in an enterprise, having a direct dependency on a Microsoft Account doesn’t work.
The good news is that today, we can associate VSO instances to an Azure Subscription.


Creating a new VSO instance is easy:


Note: if you want, an Azure Active Directory instance can be associated with your VSO instance.


And just like that, we have a new TFS instance courtesy of Visual Studio Online!!


No more having to spend unproductive time installing and configuring TFS from scratch. In a matter of minutes, we can stand up TFS with Visual Studio Online. From here, you can elect whether you want TFVC or git for your source code control. From there, it is very simple to connect your Azure Website to your new repository in order to publish from the source code repository. Like the on-prem version of TFS, you can choose your process template: CMMI, MSF Agile or Scrum. With VSO, you can also create build definitions. For more info on what VSO has to offer, check out this site. For a comparison of features between Visual Studio 2013 (On Prem) and Visual Studio Online – check out this resource.

Posted in Team Foundation Server, Visual Studio Online | Leave a comment

Restsharp, MultiPartFormDataContent File Name — 400 error

Ok, I really hate and enjoy spending 6 hours hunting down an issue. I hate it because the bug is super stupid and I have no idea why it would be this way. I enjoy it because this is what developers do, we solve issues and bugs are issues.

I have spent a total of 6 hours trying figure out why I was not able to do an HTTP post to an endpoint with a file attached. I was at an advantage because I had a working example (no direct access to the source, just the running application) so I could upload the file and capture the traffic via Fiddler.

I tried to make my post as similar as the working example, but I kept getting back a 400 error telling me that the file was not included. The problem was that the FILE WAS INCLUDED. I could see the bytes in the message via Fiddler. Finally I decided to pull the source for RestSharp.Portable locally to see if I could find the issue.

After a ton of testing I finally noticed one little difference. A difference to me looked like a non-issue… turns out it was the issue.

Here is the Fiddler results of the working post
Content-Disposition: form-data; name=”file”; filename=”awesome-desktop-wallpapers-4.jpg”

Here is the Fiddler results of the non-working post
Content-Disposition: form-data; name=file; filename=awesome-desktop-wallpapers-4.jpg;

Notice the difference? Yea the quotes around the filename header property. This was the issue. Turns out that per the w3 spec for Content-Disposition the file name SHOULD be wrapped in quotes.

To fix this issue I simply escaped my file name prior to adding it to my request and then the post uploaded.

Now on to the core issue. When stepping through the source for the Restsharp library I found the exact line of code causing the issue. Take a look at the code below, the yellow box is the bad line.


The issue is that multipartContent.Add is a part of the System.Net.Http namespace.

Turns out that if you do not have the fileName escaped it will NOT add quotes around it when the HTTP header is created. If the fileName IS escaped it will add quotes when it is added to the HTTP header.

Something does not seem right, but at least I know the issue and how to work around it.

Till next time,

Posted in C#, Uncategorized | Leave a comment

Debugging xUnit tests in Xamarin Studio and Mono Develop using The Debugging Trick™

Update: This post has been completely revamped, as it turns out there is much easier way, kudos to Michael for pointing this out. I will lament my image editing skills for a small second :-)

As I mentioned in my recent post on the Splunk blog, we’ve been developing a new awesome portable C# SDK that will support Xamarin/Mono.  We ran into a bunch of issues running on Linux with tests failing due to file paths and supporting pct-encoded URIs, so I decided to try to debug in Xamarin Studio.

I had really hoped this would be easy. It wasn’t as easy I hoped, but it turns out after a bunch of trial and error that there is a pretty simple path.  Xamarin Studio does have a “Debug Application” option, but running that all I could do was run the xUnit console runner, but I couldn’t pass it any parameters. I tried various things for a while and came up empty.

And then I decided to tweet the always helpful Michael Hutchinson to see if he had any ideas, and he did!


Update: It turns out you don’t need to do what is suggested above, and which the first version of this post recommended. 

Read on my friends to find out what you can do…..

First open Xamarin Studio to your test project. You can see I’ve done this below and I’ve added a breakpoint on the completely ridiculous, ficticious test we want to debug.

test project1

Now right click on the project, then select Options->Run->Custom Commands. Next a select Execute in the drop down. And put the following into the Command box.

“/Users/glennblock/xunit/xunit.console.clr4.exe ${TargetFile}”


The first part points to the location of the xunit console runner. The second is an expansion which will get replaced with the test dll.

Now all you have to do is run!



And that my friends is “The Debugging Trick™“!

Side note, I don’t think anyone should have to do this, though this version is far less painful than my first post. I just found out from Michael great news, that there is proper IDE support for xUnit in the works.

Screen Shot 2014-05-14 at 11.29.01 PM

This is very good news! In the meanwhile you have the trick :-).

As a side note this technique is general useful for beyond unit tests, you can use it to debug any managed exe where you need to pass arguments.

Thank you Michael Hutchinson for the help!

Posted in mono, xamarin | Leave a comment

#BeyondCallbacks or How Koa helps me Code Better

For the better part of my life I have been a C# programmer. But lately I have ventured into JavaScript land. And I like it. I have come over the “what kind of junk is this”-phase and come to see the power and beauty that is “hidden under a huge steaming pile of good intentions and blunders is an elegant, expressive programming language”. You should read that book, by the way, that’s the one that made me like JavaScript. Being a backend-guy (I will NEVER understand CSS… There – I’ve said it!) I soon came to look into Node too. And pretty soon after that I met Express. Express was very nice since it reminded me of Nancy. Felt right at home, back on the super-duper-happy-path! So after going through a lot of examples and tutorials and writing a couple of applications on my own I grew really tiered of one feature of most Node applications. That was … …wait (state)

…creating request for fact (state)

Wrapping in logger (state)

And authenticating (state)

Calling service (state)


Attaching to state

Out of callback

reformatting response and out of callback

Out of callback

There – we can continue. the fact that you need to use callbacks so extensively. Don’t get me wrong – the non-blocking principles that Node is built around is awesome. I especially like that you “fall into the pit of success” since everything is written around non-blocking code, which automatically helps my application to scale and manage resource wisely. But seriously… all those nested callbacks are making my eyes bleed. Talk about hiding the intention of the code. And I also grew very tired of trying of passing state through the chain of callbacks just to be able to use it in the final one. And for the record; Yes – I have heard about promises, but for some reason I couldn’t wrap my head around it. For me, it didn’t feel natural. Never gave it a proper chance, I’m willing to admit. But when I saw Koa Js things started to make sense again. Here is a mini-application that returns a user, from MongoDB by name sent to the URL.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// Dependencies
var koa = require('koa');
var app = koa();
var logger = require('koa-logger');
var route = require('koa-route');
// Db access
var monk = require('monk');
var wrap = require('co-monk');
var db = monk('localhost/koaDemoUsers');
var users = wrap(db.get('users'));
// Middleware
// Route
app.use(route.get('/user/:name', getUser));
// Route handling
function *getUser(userName) {
var user = yield users.findOne({name:userName});
if (!user) this.throw(404, 'invalid user name');
this.body = user;
view raw miniKoaApi.js hosted with ❤ by GitHub
thatWasGreatPretty nice, huh? Thumbs up from me! I even threw in some logging and error handling just to make it a little more interesting. Strip that out and you end up with 2,3 significant lines of code. I take my web frameworks like my coffee -  short, sweet and powerful. And we have not lost the non-blocking features that we’ve come to expect and love in Node. In short – Koa help med Code Better! In the rest of this post I’ll introduce you to the concepts of Koa and give you a short overview to how it works. Continue reading 

Posted in javascript | Leave a comment