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.
Microsoft.VCLibs
to .NET app for it to resolve Platform.IDisposable
(on a side note, I would have expected it to be projected as System.IDisposable
, but it doesn't happen...). However, adding it as reference seems to cause problems when deploying. Probably a Dev Preview quirk. –
Apothegm 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.
© 2022 - 2024 — McMap. All rights reserved.