从 C# 调用 C++/CLI 构造函数时出错

发布于 2024-10-19 18:00:09 字数 755 浏览 6 评论 0原文

我试图通过以下代码片段在 SlimDX 中使用 StateBlock 来保存和恢复状态:

StateBlockMask mask = new StateBlockMask(null) { RasterizerState = true };
var sb = new StateBlock(device.Device, mask);

StateBlockMask 和 StateBlock 都是类。这给了我一个编译错误:

'.ctor' is not supported by the language

从这里的其他一些帖子中阅读,这似乎是一个与使用错误的参数调用托管代码有关的问题。在SlimDX的源代码中,我发现:

StateBlock::StateBlock(SlimDX::Direct3D10::Device^ device, StateBlockMask mask)

我对C++/CLI没有任何经验,所以我想知道这里是否有问题(例如缺少或多余的^),或者我应该将故障集中在我这边?

(注意:这个问题已交叉发布到gamedev.net,未来有相同问题的用户可能也想检查那里给出的答案)

I am trying to save and restore state by using a StateBlock in SlimDX via the following snippet:

StateBlockMask mask = new StateBlockMask(null) { RasterizerState = true };
var sb = new StateBlock(device.Device, mask);

Both StateBlockMask and StateBlock are classes. This gives me a compilation error:

'.ctor' is not supported by the language

Reading from some other posts here on SO, it seems that this is a problem that has to do with calling the managed code with the wrong arguments. In the source of SlimDX, I find:

StateBlock::StateBlock(SlimDX::Direct3D10::Device^ device, StateBlockMask mask)

I have no experience at all with C++/CLI, so I am wondering if there is something wrong here (like a missing or extra ^), or should I concentrate of faults on my side?

(NOTE: This question has been cross-posted to gamedev.net, future users with the same question may also want to check for answers given there)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里梦着梦中梦 2024-10-26 18:00:09

StateBlockMask 是一个结构吗?如果没有,请在 C++ 构造函数中使用 StateBlockMask^ mask

Is StateBlockMask a struct? If not, use StateBlockMask^ mask in the C++ constructor.

桜花祭 2024-10-26 18:00:09

这看起来像是 SlimDX 中的一个错误。您可能需要使用问题跟踪器来确保问题得到正确处理。

This looks like a bug in SlimDX. You might want to use the issue tracker to make sure it gets dealt with properly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文