I recently upgraded my Windows::Forms application to use DirectX with Managed C++ (instead of unmanaged C++). Ever since I did it I get exceptions with the following line (even if before I succesfully built and ran my application, containing the line, several times, ) :
DeviceList * deviceList = Manager::GetDevices(DeviceClass::GameControl, EnumDevicesFlags::AttachedOnly);
(by the way is this an appropriate way for enumerating devices in Managed C++ I only found C# samples)
Reinstalling DirectX solvds the problem once but now it is happening again. Should I avoid using the managed c++ version for this application
Creating a Direct3D Device is also problematic:
PresentParameters * presentParams=
new PresentParameters();presentParams->Windowed=true;
presentParams->SwapEffect = SwapEffect::Discard;
device = new Direct3D::Device(0, DeviceType::Hardware, this, CreateFlags::SoftwareVertexProcessing, presentParams);
gives me:
error C2664: 'Microsoft::DirectX::Direct3D::Device::Device int,Microsoft::DirectX::Direct3D::DeviceType,System::IntPtr,Microsoft::DirectX::Direct3D::CreateFlags,Microsoft::DirectX::Direct3D::PresentParameters __gc * __gc[])' : cannot convert parameter 5 from 'Microsoft::DirectX::Direct3D::PresentParameters __gc *' to 'System::IntPtr'
No constructor could take the source type, or constructor overload resolution was ambiguous
(again, variations of this code usually don't change the fact that tere is no conversion from 'PresentParameters __gc *' to 'System::IntPtr'). Using instead
PresentParameters * dxapp __gc[] = {presentParams};
gives:
error C3377: 'Microsoft::DirectX::Direct3D::Device::.ctor' : cannot import method - a parameter type or the return type is inaccessible

Managed C++ DirectX Devices
Dennis Heimbigner
but it doesn't seem to work either with the suggested
namespace Microsoft
{
namespace DirectX
{
namespace PrivateImplementationDetails
{
#include <d3d9.h>
}
}
}
which actually causes another set of compilation errors
Bob Vera
With the code that worked for you I get:
d:\Rodrigo\Development\Directx2CPP\Form1.h(52): error C3377: 'Microsoft::DirectX::Direct3D::Device::.ctor' : cannot import method - a parameter type or the return type is inaccessible
d:\Rodrigo\Development\Directx2CPP\Form1.h(52): error C3377: 'Microsoft::DirectX::Direct3D::Device::get_UnmanagedComPointer' : cannot import method - a parameter type or the return type is inaccessible
d:\Rodrigo\Development\Directx2CPP\Form1.h(52): error C3377: 'Microsoft::DirectX::Direct3D::Device::UpdateUnmanagedPointer' : cannot import method - a parameter type or the return type is inaccessible
d:\Rodrigo\Development\Directx2CPP\Form1.h(52): error C3635: 'Microsoft.DirectX.PrivateImplementationDetails::IDirect3DDevice9': undefined native type used in 'Microsoft::DirectX::Direct3D::Device'; imported native types must be defined in the importing source code
d:\Rodrigo\Development\Directx2CPP\Form1.h(52): error C3635: 'Microsoft.DirectX.PrivateImplementationDetails::IDirect3DDevice9': undefined native type used in 'Microsoft::DirectX::Direct3D::Device'; imported native types must be defined in the importing source code
did you forget to include a header file
d:\Rodrigo\Development\Directx2CPP\Form1.h(52): error C3635: 'Microsoft.DirectX.PrivateImplementationDetails::IDirect3DDevice9': undefined native type used in 'Microsoft::DirectX::Direct3D::Device'; imported native types must be defined in the importing source code
did you forget to include a header file
Where can I find a sample project in managed c++, so that I can be sure all references are there
Thanx
PICASSO3
I gave up on DirectX for several months and now I' m trying again with little hope after the new SDK...
Doug Hall
Ali Akbar
this seems to work for me:
new PresentParameters();Device * dxdev = NULL;
PresentParameters * dxpp =
dxpp->SwapEffect = SwapEffect::Discard;
dxpp->Windowed = true;
PresentParameters* pArrayParams __gc[] = {dxpp};
dxdev = new Device(0, DeviceType::Hardware, Form1::renderarea, CreateFlags::SoftwareVertexProcessing, pArrayParams);