I am getting a COMException when trying to reference a method in a C# UWP class library from a C++ UWP app. This is happening with the most basic of setups, so I must be doing something wrong.
Repro:
- Using Visual Studio (I'm using 16.5.4), Create a new "Blank App (Universal Windows - c++/CX)"
- Add to the solution a new "Windows Runtime Component (Universal Windows)", C#, Called "ClassLib"
- Add this method to Class1.cs:
public static int GetNumber() { return 22; } - Modify the MainPage constructor to look like this:
using namespace ClassLib;
MainPage::MainPage()
{
InitializeComponent();
auto foo = Class1::GetNumber();
}
- Execute the application. This exception happens in the MainPage constructor:
Exception thrown at 0x76984402 in UWPApp.exe:
Microsoft C++ exception:
Platform::COMException ^ at memory location 0x0421DD44.
HRESULT:0x80131040 The text associated with this error code could not be found.