Tips, tricks, and guides for developing on modern Windows platforms
I recently had some trouble building the Windows Store version of my upcoming game, Clowntraptions. I was getting the bizarre error below:
‘Window’ is a standard class in WinRT (Windows.UI.Xaml.Window), and this error was troubling! I couldn’t build the project let alone deploy and test it. What was wrong?
I had a script in my Unity project called ‘Window’ holding a class called, of course, ‘Window’. This conflicted with the Visual Studio code that referenced a different ‘Window’ class.
So I renamed the class in my Unity project to something else and those errors went away. The class in question was actually a part of a plugin, so I wasn’t really to blame, and the plugin creator can’t be blamed for inadvertently using the same name as a Windows RT class.
Relieved, I rebuilt from Unity, opened up my game in Visual Studio, and hit the debug button to have a play test…and instead of my awesome circus game I got this before the game even managed to get past the splash screen:
Sigh. The web build was working fine, and more notably the Windows Phone 8 build was working fine…so what was causing this issue in the Windows Store build (and it was an untouched, fresh build with no extra code or plugins added in – straight from Unity). Was it a problem with the recent Unity 4.5 update? I tried everything…and was on the verge of filing a bug report…but then I had another look at my code and realised I’d made the exact same mistake I’d only just repaired. I’d created my own script a few days prior, and called it ‘Notifications’, which Visual Studio got confused with ‘Windows.UI.Notifications’. I renamed my script and class to something different and, Hey Presto! My build was then successful.
So if you come across weird errors like above in Unity projects that work on other platforms, make sure you don’t have any poorly named classes that clash with existing Windows classes.
To avoid these mistakes: