THE SCENARIO:
I am making a [edit: native WinRT] C++ Direct X DLL project for Windows Store apps based on the "Direct3D App" Visual Studio code sample.
This must be a separate DLL project from my Windows Store App project because I will be using my XAML UserControl with Direct X renderer inside it both in the Windows 8 Metro app and a Windows Phone version of the app.
THE PROBLEM:
I cannot reference the C++ project in the C# Windows Store app project. Visual Studio refuses with the following words:
A reference to <project-name> could not be added.
I've seen suggestions to compile the C++ project using the /clr flag, but this is not compatible with:
So the /clr flag does not appear to be an option in this situation.
THE QUESTION:
How can I reference the C++ project so that I can use my XAML Direct X renderer within the C# Windows Store App project? Or is there a better alternative?
Thanks in advance.
I solved the problem by re-creating the C++ project as a Windows Runtime Component
project. I had originally created the project from the Class Library (Windows Store apps)
template. It must be that the Win RT template has some configuration settings which enable it to work.
After making this change, the project could be added as a reference in the C# project.
It is because of @user1610015's answer that I realised I was actually developing native Win RT code, not managed code, which lead me to try this solution - thanks!
The /ZW flag is for C++/CX projects. C++/CX is almost identical in syntax to managed C++ (C++/CLI), except that C++/CX is completely unmanaged. This may be what made you think you were developing managed C++, when in fact you weren't.
I haven't used C++/CX, but from what I've heard, Windows Runtime classes are COM classes. So I think you can use the TlbImp.exe tool from the Windows SDK to create a managed DLL from your unmanaged DLL, which you can then reference from your C# project. Try it and let me know if it works.
Another option is to talk to the Windows Runtime without C++/CX. While C++/CX makes Windows Runtime programming a lot easier, it's not strictly necessary. You can also use the WRL library. Since the WRL library is pure C++, it should also be usable from C++/CLI.
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