Most probably, this is because you have not initialized Playback.
In this post, Gautam has described how to use UI Testing methods without creating a Coded UI Test. It is important to note that, If Playback.Initialize() is not called before invoking any UI Testing method, an exception will be thrown.
- If you attempt to call UITestControl.Find() method (without calling Playback.Initialize), you will get a NullReferenceException. Note that there is an implicit Find() call whenever we act on a UI Test Control (unless it has previously been found and is available in the cache).
- If you attempt to call BrowserWindow.Launch() method (without calling Playback.Initialize), you will get a TechnologyNotSupportedException
In a Coded UI Test, Playback.Initialize() and Playback.Cleanup() are called implicitly.