Most Popular Posts

  • There has not been recent blog activity

Most Commented On

  • There has not been recent blog activity

Current Bloggers



  • You have not yet contributed to any pages.

TypeScriptCompile “Include” error when loading a Project

Posted by Derik Whittaker, Wednesday, May 29, 2013 (3,008 views)

Today when opening one of our .sln files we received the following error message when trying to load a web project.

The Attribute "Include" in element <TypeScriptCompile>

Of course the first thing we did was open the .csproj file but nothing seemed ‘out of whack’.  When we opened the file we saw what we thought was the issue, but it turned out to be a false negative.  The false negative is below.



It was not until we started to really, really took a look at the changes line by line that we noticed the issue (even then we glossed over the issue a few times first).

Here is the xml which is the issue




Notice how the merge had put a <TypeScriptCompile> element inside of a <Content> element, this is NOT allowed.  Once we moved the <TypeScriptCompile> element the project opened just fine and we were able to compile.

Till next time,

P.S. If you want to learn more about Knockout watch my Pluralsight Course on Knockout JS


P.S.S. If you want to learn how to transition your XAML skills to HTML you can watch my course on Html for the XAML Developer

Filed under:
Discuss (0)

.NetRocks - Making the Transition from XAML to Html

Posted by Derik Whittaker, Tuesday, May 21, 2013 (3,222 views)

Recently I sat down as a guest with Richard and Carl on .Net Rocks and recorded a show on my experiences on migrating from XAML to HTML.  Chatting w/ Richard and Carl is always great. 

In this episode we tried to focus on my experiences on moving from XAML to Html but when you have 3 guys w/ A.D.D. staying on course is always a challenge :)  We were able to talk about:

  • We talked about TypeScript and how it can make the conversion from .Net to JavaScript easier
  • We talked about MVVM and how developers LOVE this pattern
  • We talked about how Winforms is still prevalent in the corporate world… DEAL WITH IT
  • We talked about many of the things in XAML that can translate to HTML
    • MVVM
    • Knockout
    • XAML layout concepts loosely translate to HTML layout concepts
  • We talked about my Pluralsight course on Html from the XAML Developer
    • Even plugged my next Pluralsight course – MVVM w/ Knockout for the XAML developer

Again, thanks Richard and Carl, I had a BLAST.

Till next time,

P.S. If you want to learn more about Knockout watch my Pluralsight Course on Knockout JS


P.S.S. If you want to learn how to transition your XAML skills to HTML you can watch my course on Html for the XAML Developer

Discuss (0)

TypeScript references not being created correctly during drag-n-drop

Posted by Derik Whittaker, Monday, May 13, 2013 (3,489 views)

One of the viewers of my Html for the XAML developer course over on Pluralsight sent me a question regarding the ability to drag and drop a d.ts file onto a TypeScript file and have the reference added correctly.

He said that when he dropped the d.ts file he was expecting to get something like:

/// <reference path="../something.d.ts" />

However, what he got was:


To be honest I was not sure what the issue was but did ask 2 questions:

  1. Do you have the TypeScript IDE plugin installed?
  2. Do you have Web Essentials installed?

Turns out he did not have Web Essentials installed, which it appears is what gives you the nice ability to drag-drop a Typescript file into your editor and have it provide the correct reference syntax.  I honestly was not aware that it was Web Essentials which did this, just assumed it was part of the TypeScript plugin.

Moral of the story, if you have not already installed Web Essentials DO SO NOW…!

Till next time,

P.S. If you want to learn more about Knockout watch my Pluralsight Course on Knockout JS


P.S.S. If you want to learn how to transition your XAML skills to HTML you can watch my course on Html for the XAML Developer

Filed under:
Discuss (0)

Typescript Bundler Issue - Not transforming to JavaScript

Posted by Derik Whittaker, Saturday, May 11, 2013 (3,742 views)

Today one of the viewers of my Pluralsight course was having issues and I was trying to help him via email, but to no avail.  I asked him to send me his project so I could take a look myself.  I ran the project and sure enough things were odd.  I looked at his Typescript syntax and everything looked right, as you see below.


I next took a look to ensure the JavaScript was being loaded correctly and at first glance everything looked right, but then I noticed that the loaded file was NOT JavaScript but rather the raw, untransformed TypeScript.  At this second I knew the issue.  The Bundler was not bundling the Typescript and turning it into JavaScript.

I checked the bundle configuration and everything looked ok, but clearly there was an issue.  After some continued looking I noticed that the TypeScript Bundlertransformer had not been installed. 

Once I added the BundleTransformer.Typescript nuget package and recompile the application the world was a happy place.

Till next time,

P.S. If you are looking to make the jump from XAML based development to HTML development check out my HTML for the XAML Developer Pluralsight course

Filed under:
Discuss (0)

Putting the Dynamic back into TypeScript

Posted by Derik Whittaker, Wednesday, May 08, 2013 (7,579 views)

One of the really powerful features that TypeScript brings to the JavaScript world is some Static Typing, even if it is only at code/compile time.  With TypeScript I can say that an object is of a certain type which implies there are only a limited set of properties/methods available to me.  This is great, but it does limit the core power of JavaScript and dynamic languages in general.

Given the static nature of TypeScript, (yes I can choose to ignore this feature, but why?) which I want in most cases, the following will cause me compile time issues.


The reason this is causing me issues is because MemberInitContext does NOT contain a LoadChoachingStaffStats property, but I know that the caller may provide an object which does contain this object.   Below is my definition for MemberInitContext.


Given I know this property MAY be provided at runtime I have a decision to make.  I can do any of the following to resolve my build errors.

  • Add the property to the MemberInitContext
  • Create a inherited type which contains this property
  • Change my constructor to take an ‘any’ rather than a type
  • Add the dynamic back into TypeScript

I am going to choose the last option here, but how?  Simple, by redefining the variable to an any INSIDE my constructor as below.


By declaring my type as an ‘any’ TypeScript is happy and lets me hack away and complete my tasks.

Long story shot is that even though TypeScript tries to impose Static typing, which is AWESOME in most cases, you can still force it back to dynamic if you want.

Till Next Time,

P.S. Check out my HTML for the XAML developer course on Pluralsight

Filed under: ,
Discuss (9)

My first Pluralsight course (HTML for the XAML Developer) as gone live

Posted by Derik Whittaker, Monday, May 06, 2013 (3,777 views)

For the past 2 months I have been working on my first Pluralsight course, and it has finally gone LIVE.  I had a great time building this course and I hope it shows.  In fact I enjoyed it so much I am currently working on my 2nd course.

This course, HTML for the XAML Developer is intended to help XAML based developers (WPF or Silverlight) make the transition to HTML development.  I take you, the viewer, through the exercise of porting an existing XAML based application over to be an HTML based one.  In this course I used many frameworks but I tried to keep it as vanilla as possible.  I know there are 100 different ways to to build HTML sites and even more tools and libraries but I really wanted to focus on many of the basics.

I hope everyone who watches will enjoy the course.

Module Listings

  • Getting Started – Overview of what we are going to be working on along w/ a quick start of some of the tools
  • Porting our ToDo Listing Screen – Part 1 - Introduce many of the basics and build a simple listing screen of items
  • Porting our ToDo Listing Screen – Part 2 – Add some styling and enhanced features
  • Porting our ToDo Maintenance Screen – Part 1 – Introduce many data entry techniques and basis persistence.
  • Porting our ToDo Maintenance Screen – Part 2 – Data Validation


Till next time,

Filed under:
Discuss (1)

Inheritance issue w/ Typescript (JavaScript) and MVC Bundling Ordering

Posted by Derik Whittaker, Tuesday, April 30, 2013 (4,835 views)

Today I extended one of our classes to use inheritance via Typescript (love that).  When I refreshed the page I received an error here


When I dropped to the Chrome debugger and outputted both the values for both ‘d’ and ‘b’ I was a bit shocked.  ‘d’ was valid, but ‘b’ was undefined.  I tried a whole slew of things but nothing came to mind.  Of course I thought maybe I was using inheritance wrong, but my syntax was right.

After some digging online I found this link which talks about how a parent class has to be loaded prior to it child for everything to work.  This makes perfect sense given the way JavaScript parses code.  I had this brilliant idea that I would simply add a _ prefix to my base class name and that would have the file loaded first.  WRONG…

If you look at the image below you can see that _BaseViewModel.js is way at the bottom of the list and my error was being thrown in the AthleteListingViewModel…


Somehow I needed to force the bundler to load the files in the order I wanted.  In our case I am NOT including each file into the bundle manually, rather I am using the ‘IncludeDirectory’ feature. 

After a bit more searching I found this link which solved the same basic problem but in a much more complex way than I needed.  However it showed me how I could solve the problem in a few lines of code.  What I needed to do was create a new instance of IBundleOrderer and use it.

This code is my AlphaSortedBundleOrderer which solved my issues.


After I created my new AlphaSortedBundleOrdered I just needed to use it in my bundler.  I did this as you see below.


Once I had my bundler setup correctly I re-ran the page and my .js files were ordered as expected.


Now I am sure there is a 100 ways to solve this problem, but this worked for me.

Till next time,

Discuss (2)

Knockout Click binding and the ‘this’ context

Posted by Derik Whittaker, Monday, April 29, 2013 (4,255 views)

When using Knockout JS wiring to the click binding is cake and simply just works.  Or does it?

Per the documentation there are multiple ways to wire the click binding within your html.  Assume you have a method such as (the code below is TypeScript)

You can do any of the following:

All of the above will accomplish the same goal, passing in the current $data object into the underlying method.  However, what appears to be the same is actually quite different.  The difference comes in when you are going to use the ‘this’ context.  Lets take a deeper look.

‘this’ context for option 1:


‘this’ context for option 2:


‘this’ context for option 3:


Did you notice the difference?  2 of the options (1 & 3) set the ‘this’ context equal to the passed in $data object.  Option 2 has the context set to the $parent object (in our case the view model).

Now I am NOT saying which one is right and which one is wrong because they are all right.  However, I just want to make sure everyone is aware of the differences.  In many cases i use option 2 because I want direct access to the underlying view model and this provides this.

I am sure there are many different ways in JavaScript/Knockout to get the parent View Model but honestly I like low friction and option 2 provides this for me.

Till next time.

Filed under: ,
Discuss (2)

Validating all observables w/ Knockout validation and Typescript

Posted by Derik Whittaker, Sunday, April 21, 2013 (5,091 views)

Knockout js is an awesome MVVM framework for HTML/Javascript development and there is an extension library which performs data validation called Knockout.Validation which is an equally awesome library.  Today when doing some coding I needed to validate that all properties on a VM were valid. A quick search showed me this was very easy and should just work.  However, I am using Typescript and for all of its awesomeness it sometimes makes life a bit more challenging than expected.

To validate an entire observable all you should need to do is first tell the validation library that your vm is under validation by doing


and then you can simply call a .isValid() on your VM as such.


However, when doing this in Typescript I was getting the red squiggly as you see here.


At first I was not sure why, so I decided to take a peek at the source for the validation and I came across the code you see below.


As you can see, the highlighted yellow is where the .isValid() method is being added to object (obj == your passed in viiew model) so I KNOW that my view model has a .isValid.  Sure enough at runtime if I hit a breakpoint and did this.isValid() i would get the response I was expecting.  However, because .isValid() was being added to my VM dynamically (this is the amazing power of JavaScript) Typescript did not know about the method and it was causing compile time errors.

How to fix this?

The simple solution that I found was to ‘fake’ Typescript into thinking that the .isValid computed is on my VM from the start.  I did this by adding the following to my VM


Now you will notice that I am simply declaring the computed I am NO assigning it and that is ok.  In fact if you look at the generated output from the Typescript compiler you will NOT see a computed created for .isValid().  But this does not matter.  The Typescript compiler thinks it is there so you are free to use it off of your VM as you see here.


After adding my declaration for isValid() I was good to go and my code worked as expected both at code time and run time.

Till next time,

Discuss (1)

Typescript, jQuery and the ‘this’ context causing issues

Posted by Derik Whittaker, Friday, April 12, 2013 (4,173 views)

Today I was in the middle of porting some raw javascript over to TypeScript as well as moving inline javascript into separate classes.  In the middle of doing this I started to run into some really odd stuff.  Namely, the ‘this’ context in one of my methods was set to window, not to the parent object.  This was really weird and at first I thought maybe it had to do w/ Inheritance and Typescript (this class implemented a base class).  Sadly even when I removed the base class I was still getting the results.

After a bunch of digging I was able to find the root cause, Derik was doing something stupid and jQuery was making it worse :)

In order to get some feedback and to help illustrate my issue.

Here is what my Typescript class which was having the issue looked like.  The box in red is what was throwing the error.


From Chrome’s debugger when I would output ‘this’ it would be the browsers window object, not my parents object.  This told me something was screwed up but I could not find the cause.  That was until I started walking the call stack to see WHERE PerformSearch was being called.  Turns out PerformSearch was being called by jQuery… that was odd.  In fact below is the code making the call.



Again, why was jQuery calling my method I had not told it to.  Well I kept walking the stack and I realized that this was being called during a .ajax call as seen below.


It turns out that the ‘data’ object I was passing across the wire was not just a property bag, but it had methods.  These methods referenced ‘this’ and when jQuery tried to searlize the object it is executing the functions, and when it does the ‘this’ context is wrong and BOOM.

To solve this issue I simply refactored my code to NOT have a method and then it just worked.

My question is this.  Is what I was doing just dumb and I was an idiot, or is there a way to tell jQuery to NOT try and call my methods during serialization? 

Till Next time,

P.S. I know I could have guarded against this in my method by checking that ‘this != window’ but that felt dirty and I had a better solution.

Filed under: ,
Discuss (1)

Moving a TFS Git Repository to Github

Posted by Derik Whittaker, Tuesday, April 09, 2013 (6,241 views)

We gave using the git support in TFS the old college try but the friction and issues were just too much so we decided to move our repository over to github.  I am not going to go over our issues w/ TFS git here, but I am thinking of creating a separate post for it.

Because we already had our repository w/ change history setup all we really wanted to do was ‘change remote origin’ for our repository and here are the steps WE took to accomplish this.

Our Steps (it is assume you already have a github account setup)

  1. Go to and create your repository.
  2. Create a copy of your existing tfs/git source and move it to a new directly.  I do this simply to ensure I don’t screw anything up and have to do a new pull (i am lazy and xcopy is faster). 
    1. from c:\TFSRepo –> c:\GithubRepo
  3. Open a git command prompt and CD into the destination directory from step 1
  4. From the command prompt run ‘git remote –v’  this command is a sanity check to double check the current origin of your repository
  5. From the command prompt run ‘git remote rm origin’ this command will remove/clear the origin settings for your reporsitory
  6. From the command prompt run ‘git remote add origin[AccountUserNameHere]/[RepoNameHere].git’ this command will set the origin information to your new repository path in github.  Pay attention to the url’s casing as github is case sensitive and you may experience issues if the casing is off. 
    1. PS. You can get the url above from the github repository page
  7. From the command prompt run ‘git push origin master’ this command will push your current files up to github and publish them.  Please note that this will ONLY push the master branch.  If you want to push other branches you will need to do a ‘git push origin [branchnamehere]’ for each branch.
  8. Refresh the project page and rejoice in the fact that you are out of TFS and your pain should be greatly reduced :)

These are the steps that worked for us, of course they may be different or better ways, but again these worked for us.

Till next time,

Filed under: ,
Discuss (8)

Using Entity Framework Profiler to find Undisposed Object Context’s

Posted by Derik Whittaker, Friday, March 29, 2013 (4,009 views)

If you are using Entity Framework, or any other ORM for that matter you need to head over to Hibernating Rhinos and buy a copy of Entity Framework Profiler, the license will pay for itself in no time flat.

When using any ORM, but in our case EF it is recommended, ok I would say required that you dispose or close your Data Context once you are done with your database transitions.  Not closing the context will not immediately bring your system to its knees, but over time as your grow and scale you are going to start noticing memory and performance issues.  Sure, you can let the .Net Garbage collector dispose of your context, but you really should be a responsible developer and clean up after yourself, trust me it is worth the effort.

When using EFProfiler you can very easily determine when you left a context dangling open, all you need to do is look at the timings on the executed statements as seen below.


Here is the code which produced the above

Now I am only showing you the creation of this because as you can assume it was NEVER closed.

To close this I could manually call the .Dispose method or I could use a using statement as seen here

By using the Using statement above I am explicitly telling the runtime to close the connection, thus freeing my resources and reducing my over head.  The image below shows the statement now


As you can see you can find open connections w/ little ease using Entity Framework profiler.

Till next time,

Filed under:
Discuss (1)

Windows 8 Development w/ C# and XAML – Video Shoot

Posted by Derik Whittaker, Friday, March 22, 2013 (4,059 views)

A while back I was commissioned to do a video series for Pearson Education.  This series will be available on their site as well as on Safari online in the near future.  One of the unique things Pearson does for their videos is video headshots of you introducing your lessons, which by the way is way harder than I ever thought.

Yesterday the videographer stopped by to do the shoot and I took a few photos so I thought I would share them.

WP_000004WP_000003 WP_000002 WP_000001 WP_000000


When I have the link to the live content I will share it here as well.

Till next time,

Filed under: , ,
Discuss (7)

Deploying Database Projects with psake

Posted by Derik Whittaker, Tuesday, March 19, 2013 (4,069 views)

Recently I joined a project that was using a Sql Server Database Project to manage their DB scheme and so far it is pretty cool.  This project type like others has a deploy/publish option which will allow you to publish your changes to a target database.  And like other project types this is very easy to do via Visual Studio, but if you know me you will know that I like to automate tasks like these rather than have to use the IDE so I did.  Here is what I did in order to use pSake, a build automation tool written in powershell, to handle my clean, build and deployment of my database projects.

Step 1: Learn

Understand the automation options available for this project type and MSBuild

Step 2: Create your psake task file (database.upgrade.ps1)

**** Please not that the formatting of the MSBuild above will NOT RUN and is done to allow the sample code to be clean.  You the entire MSBuild task needs to be on ONE LINE ****

**** I am setting my properties to ‘parm’ variables because I am passing these into the script by using the –parameters feature of psake ****

There is one part of the MSBuild task above that you MUST PAY ATTENTION TO, that is the way items are escaped.  They are being escaped with the back tick (`).  If you omit this you are going to get some odd errors depending on what you do.  These errors could range from ‘Multiple projects were provided’ to issues with the connection string not being formatted.  The root cause for these errors and the need to use the back tick (`) has to do with white space in the connection string… ugg

One you have this psake task setup you can call it like any other task and it should just work.

Till next time,

Filed under: ,
Discuss (6)

Durandal 1.2.0 and Caliburn.Micro 1.5.0 Released!

Posted by Rob Eisenberg, Monday, March 18, 2013 (6,805 views)

Two awesome releases in the last week! Much thanks to the great community surrounding both projects! Here’s what’s new:

Durandal 1.2.0

  • Tons of bug fixes.
  • Lots of improvements to the router.
  • Better support for integrating with Q, KendoUI and Dojo.
  • More docs.

Check out the full set of changes.

Caliburn.Micro. 1.5.0

Nigel Sampson and Thomas Ibel are going to town these days! Some really cool stuff happening in this release. Here’s a few things:

  • Task and Async support (on all platforms except SL4 and WP71)
  • Task/Coroutine integration.
  • Actions can return tasks.
  • More async stuff in general.
  • Support for the WinRT Share Charm
  • Support for the WinRT Settings Charm
  • Various bug fixes and minor improvements throughout.

You can get the latest versions of both of these frameworks on Nuget.

More Posts « Previous page - Next page »

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)