Error calling C++/CLI constructor from C#

602 views Asked by At

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)

2

There are 2 answers

3
Lou Franco On BEST ANSWER

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

1
MikeP On

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