It's been said that you can create a C++ WinRT component that you can consume in C#. I have a simple test project - a C# XAML app, and a C++ project using just the basic WinRT Component project template. When I try to add a project reference in the C# XAML project, it says it cannot add the reference (not sure why). I can build the native WinRT component, and a .winmd file is generated, and I can add a reference to this .winmd file manually using the browse button in the add reference dialog. This allows me to access the methods in the native library, but when I build, it says it is using Platform.IDisposable, but that type is defined in an assembly that isn't referenced. I haven't seen any of the sessions demonstrate this scenario.
Found the answer! Looks like it's a glitch, but it has a work-around: http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/1900bd21-8693-4127-800a-f35cfd5daac2
Basically, first you clean the WinRT component project, then you add the reference, then add a reference manually to platform.winmd located in \VC\bin then you should be good to go.
The C++ WinRT assembly you are referencing probably uses objects that are implementing the IDisposable interface so you also have to reference the C++ assembly containing the interface.
So I run into similar issues, after adding a reference to Microsoft.VCLibs, i wasn't able to deploy. However I noticed, that by default WinRT component is compiled to x86 code whereas the C# Metro style app targets ANY cpu, and this was a root cause in my case. Switching C# app to x86 resolved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With