سؤال

i'm trying to wrap D3D11 calls in an API ive been developing.

Ive made a C++/CX component library that i'm trying to use in C#. This is simple and straightforward if the C++/CX component and C# project are in the SAME solution, everything will work fine...

...but if I create my C++/CX API component in its OWN solution then create a second C# Metro App solution and add my C++/CX component "project" to it and then have my C# Metro App reference the C++/CX component project I get runtime errors when trying to use public enums that were declared in C++.

Here is the public enum class error that my C# app cant seem to link to.

"Could not find Windows Runtime type 'Reign.Video.D3D11.FeatureLevels'."

This is rly frustrating as I can't seem to get my C++/CX "API" stuff to link correctly in a C# app for TESTING. How are you suppose to productively test an API made in C++ on metro?? You can't link a C++/CX component to a C# project unless there in the same solution and if you try to link the C++/CX project to the C# solution and link it from there you get runtime errors...

EDIT: Here is a download link of a demo showing my issue: Download

هل كانت مفيدة؟

المحلول

Windows Runtime requires that all types must be found in a namespace that matches the name of the containing .winmd file. In the demo you linked, your generated winmd is named ExternalWindowsRuntimeComponentProject.winmd but your non-working class is found in the Reign.Video.D3D11 namespace. This is not permitted by WinRT and the .NET type loader will fail to find types that are not in an associated namespace.

The solution here is to make sure the FeatureLevels enum is in a winmd named either Reign.winmd, Reign.Video.winmd, or Reign.Video.D3D11.winmd.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top