   ERROR CXX0030
  hi,my program has to simply initialize a button. I looked at the directx example CustomUI and cut it a little so it just show a button(and its perfectly working). So the problem is that Im making a dll file and I've copied the function from CustomUI but when i start the main function i have this error for pD3D:__vfptrCXX0030: Error: expression cannot be evaluatedso here is the dll file:#define _WIN32_WINNT 0x0400 #include "stdafx.h"#include "Windows.h"#include "WindowsX.h"#include "WinUser.h"#include "zmouse.h"#define IDC_TOGGLEFULLSCREEN    1#include "dxstdafx.h"#include "DXUT.h"#include "DXUT.cpp"#include "DXUTgui.h"#include "DXUTgui.cpp"#include "DXUTmisc.h"#include "DXUTmisc.cpp"#include "DXUTenum.h"#include "DXUTenum.cpp"#include <d3d9types.h>#include "DXUTsettingsDlg.h"#include "DXUTsettingsDlg.cpp"__declspec(dllexport)ID3DXFont*    g_pFont;    // Font for drawing text__declspec(dllexport)ID3DXSprite*  g_pTextSprite;   // Sprite for batching draw text calls__declspec(dllexport)D3DXMATRIXA16 g_mView;__declspec(dllexport)CModelViewerCamera g_Camera;// A model viewing camera__declspec(dllexport)CDXUTDialogResourceManager g_DialogResourceManager; // manager for shared resources of dialogs__declspec(dllexport)CDXUTDialog   g_HUD;// dialog for standard controls//__declspec(dllexport)IDirect3D9* pD3D;__declspec(dllexport)bool    CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext );__declspec(dllexport)bool    CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext );__declspec(dllexport)HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );__declspec(dllexport)HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );__declspec(dllexport)void    CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );__declspec(dllexport)void    CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );__declspec(dllexport)LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext );__declspec(dllexport)void    CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext );__declspec(dllexport)void    CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext );__declspec(dllexport)void    CALLBACK OnLostDevice( void* pUserContext );__declspec(dllexport)void    CALLBACK OnDestroyDevice( void* pUserContext );__declspec(dllexport)void    InitApp();BOOL APIENTRY DllMain( HANDLE hModule,    DWORD  ul_reason_for_call,    LPVOID lpReserved ){    return TRUE;}__declspec(dllexport)void InitApp(){    g_HUD.Init( &g_DialogResourceManager );    g_HUD.SetCallback( OnGUIEvent ); int iY = 10;g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 35, iY, 125, 22 );}__declspec(dllexport)bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext ){  // Skip backbuffer formats that don't support alpha blending   IDirect3D9* pD3D = DXUTGetD3DObject(); if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType,AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat ) ) )//<--HERE IS THE ERRORreturn false;    // Must support pixel shader 1.1    if( pCaps->PixelShaderVersion < D3DPS_VERSION( 1, 1 ) )   return false;    return true;}__declspec(dllexport)bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext ){    if( (pCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||    pCaps->VertexShaderVersion < D3DVS_VERSION(1,1) )    {   pDeviceSettings->BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;    } // Debugging vertex shaders requires either REF or software vertex processing// and debugging pixel shaders requires REF.  #ifdef DEBUG_VS    if( pDeviceSettings->DeviceType != D3DDEVTYPE_REF )    {   pDeviceSettings->BehaviorFlags &= ~D3DCREATE_HARDWARE_VERTEXPROCESSING;   pDeviceSettings->BehaviorFlags &= ~D3DCREATE_PUREDEVICE; pDeviceSettings->BehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;    }#endif#ifdef DEBUG_PS    pDeviceSettings->DeviceType = D3DDEVTYPE_REF;#endif    // For the first device created if its a REF device, optionally display a warning dialog box    static bool s_bFirstTime = true;    if( s_bFirstTime )    {   s_bFirstTime = false;   if( pDeviceSettings->DeviceType == D3DDEVTYPE_REF )  DXUTDisplaySwitchingToREFWarning();    }    return true;}__declspec(dllexport)HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ){HRESULT hr;V_RETURN( g_DialogResourceManager.OnCreateDevice( pd3dDevice ) );V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_pFont ) );    DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;    #ifdef DEBUG_VS   dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;    #endif    #ifdef DEBUG_PS   dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;    #endif   // Setup the camera's view parameters    D3DXVECTOR3 vecEye(0.0f, 1.5f, -7.0f);    D3DXVECTOR3 vecAt (0.0f, 0.2f, 0.0f);    D3DXVECTOR3 vecUp (0.0f, 1.0f, 0.0f );    g_Camera.SetViewParams( &vecEye, &vecAt );    D3DXMatrixLookAtLH( &g_mView, &vecEye, &vecAt, &vecUp );    return S_OK;}__declspec(dllexport)HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice,   const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ){    HRESULT hr;    V_RETURN( g_DialogResourceManager.OnResetDevice() );    if( g_pFont )   V_RETURN( g_pFont->OnResetDevice() ); // Create a sprite to help batch calls when drawing many lines of text    V_RETURN( D3DXCreateSprite( pd3dDevice, &g_pTextSprite ) );    // Setup the camera's projection parameters    float fAspectRatio = pBackBufferSurfaceDesc->Width / (FLOAT)pBackBufferSurfaceDesc->Height;    g_Camera.SetProjParams( D3DX_PI/4, fAspectRatio, 0.1f, 1000.0f );    g_Camera.SetWindow( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height );    g_HUD.SetLocation( pBackBufferSurfaceDesc->Width-170, 0 );    g_HUD.SetSize( 170, 170 );    return S_OK;}__declspec(dllexport)void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ){    D3DXMATRIXA16 m;    D3DXMatrixRotationY( &m, D3DX_PI * fElapsedTime / 40.0f );    D3DXMatrixMultiply( &g_mView, &m, &g_mView );}__declspec(dllexport)void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ){    // If the settings dialog is being shown, then    // render it instead of rendering the app's scene    HRESULT hr;    D3DXMATRIXA16 mWorld;    D3DXMATRIXA16 mView;    D3DXMATRIXA16 mProj;    D3DXMATRIXA16 mWorldViewProjection;   // Clear the render target and the zbufferV( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0) );    // Render the scene    if( SUCCEEDED( pd3dDevice->BeginScene() ) )    {   V( g_HUD.OnRender( fElapsedTime ) );   V( pd3dDevice->EndScene() );    }}__declspec(dllexport)LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext ){    // Always allow dialog resource manager calls to handle global messages    // so GUI state is updated correctly    *pbNoFurtherProcessing = g_DialogResourceManager.MsgProc( hWnd, uMsg, wParam, lParam );    if( *pbNoFurtherProcessing )   return 0;// Give the dialogs a chance to handle the message first    *pbNoFurtherProcessing = g_HUD.MsgProc( hWnd, uMsg, wParam, lParam );    if( *pbNoFurtherProcessing )   return 0;    // Pass all remaining windows messages to camera so it can respond to user input    g_Camera.HandleMessages( hWnd, uMsg, wParam, lParam );    return 0;}__declspec(dllexport)void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext ){}__declspec(dllexport)void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ){    WCHAR wszOutput[1024];    switch( nControlID )    {   case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break;    }}__declspec(dllexport)void CALLBACK OnLostDevice( void* pUserContext ){    g_DialogResourceManager.OnLostDevice();    if( g_pFont )   g_pFont->OnLostDevice();    SAFE_RELEASE(g_pTextSprite);}__declspec(dllexport)void CALLBACK OnDestroyDevice( void* pUserContext ){    g_DialogResourceManager.OnDestroyDevice();    SAFE_RELEASE(g_pFont);}...and that's the main function:#define IDC_TOGGLEFULLSCREEN    1#include <windows.h> // include all the windows headers#include <windowsx.h> // include useful macros#include "dxstdafx.h"#include "zmouse.h"#include "DXUT.h"#include "DXUT.cpp"#include "DXUTgui.h"#include "DXUTgui.cpp"#include "DXUTmisc.h"#include "DXUTmisc.cpp"#include "DXUTenum.h"#include "DXUTenum.cpp"#include <d3d9types.h>#include "DXUTsettingsDlg.h"#include "DXUTsettingsDlg.cpp"#include "TW_INITDX9.h"INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int ){    // Enable run-time memory check for debug builds.#if defined(DEBUG) | defined(_DEBUG)    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );#endif    ID3DXFont*    g_pFont = NULL;    // Font for drawing text    ID3DXSprite*  g_pTextSprite = NULL;    DXUTSetCallbackDeviceCreated( OnCreateDevice );    DXUTSetCallbackDeviceReset( OnResetDevice );    DXUTSetCallbackDeviceLost( OnLostDevice );    DXUTSetCallbackDeviceDestroyed( OnDestroyDevice );    DXUTSetCallbackMsgProc( MsgProc );    DXUTSetCallbackKeyboard( KeyboardProc );    DXUTSetCallbackFrameRender( OnFrameRender );    DXUTSetCallbackFrameMove( OnFrameMove );    // Show the cursor and clip it when in full screen    DXUTSetCursorSettings( true, true );    InitApp();    DXUTInit( true, true, true );DXUTCreateWindow( L"CustomUI" );    DXUTCreateDevice( D3DADAPTER_DEFAULT, true, 1024, 768, IsDeviceAcceptable, ModifyDeviceSettings );    DXUTMainLoop();    return DXUTGetExitCode();}I think the problem is that DXUTGetD3DObject() returns NULL but I cant understand why when all the functions are in the main file there is no error and the program works fine.   
  Moved to the DirectX forum.Btw: the .NET forum is explicitly only about the managed .NET environment, not about unmanaged applications created with Visual Studio .NET.   