danielwertheim

danielwertheim


notes from a passionate developer

Share


Sections


Tags


Disclaimer

This is a personal blog. The opinions expressed here represent my own and not those of my employer, nor current or previous. All content is published "as is", without warranty of any kind and I don't take any responsibility and can't be liable for any claims, damages or other liabilities that might be caused by the content.

IConvertible in WinRT/NetFX/Metro

I have a small piece of code that tests if a variable implements IConvertible by using x is IConvertible. I have three different projects running the same code. One for .Net4.0, one for .Net4.5 (both working fine) and one for WinRT/NetFX/Metro which of course doesn’t work.

Inspecting e.g Int32 in the reference: .NET for Windows Store apps; for the WinRT lib, in the Object browser, reveals an implementation of IConvertible but the compiler can not resolve it.

iconvertible-winrt-int32

To ensure I hadn’t messed to much up, I created a new solution, with a Windows store apps Unit test library and a new Windows store Class library. Pure Microsoft stuff. The test looks like this:

iconvertible-winrt-notfound

And a simple implementation for extracting the interface from Int32:

iconvertible-extractinterface

It can resolve the interface, but I can’t use it in code. There are no more references I can add to the project and I haven’t found a BCL extension distributed as a NuGet that I can use as a standin.

iconvertible-nomorerefs

I know WinRT isn’t .Net, but instead, it supports a subset of .Net. For me, it sometimes feels like it would make more sense to not support anything of the .Net API and instead go all new instead of making it hard for us to have it coexist with each other, as I do think issues like these make it a to limited subset.

Anyway, if you can spread light on the issue, I’m more than grateful.

Thanks,

//Daniel

View Comments