【发布时间】:2020-09-07 11:23:17
【问题描述】:
我在尝试从 C++ UWP 应用程序引用 C# UWP 类库中的方法时收到 COMException。这发生在最基本的设置中,所以我一定做错了什么。
复制:
- 使用 Visual Studio(我使用的是 16.5.4),新建一个“空白应用(通用 Windows - c++/CX)”
- 向解决方案添加一个新的“Windows 运行时组件(通用 Windows)”,C#,称为“ClassLib”
- 将此方法添加到 Class1.cs:
public static int GetNumber() { return 22; } - 将 MainPage 构造函数修改为如下所示:
using namespace ClassLib;
MainPage::MainPage()
{
InitializeComponent();
auto foo = Class1::GetNumber();
}
- 执行应用程序。此异常发生在 MainPage 构造函数中:
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.
【问题讨论】:
-
下面的答案有帮助吗?你的问题解决了吗?
-
您好,您的问题解决了吗?我也面临同样的问题。
标签: c# c++ uwp win-universal-app c++-cx