Rob
Rob

Reputation: 39

Can't link c# .Net Core 3.0 with directx 9.0 dependency

I have a C# WPF Avalon dock App that works great under .Net Core 3.0. I also have a pile of C++ native code that for which I've written a C++ .Net wrapper which I'm trying to integrate in. Everything links ok, but when it tries to load my wrapper DLL it crashes with a "An attempt was made to load a program with an incorrect format." error.

I've tried calling a C++ logging method in a different C++ library with no issues. I copied all the compile parameters from this library to my directx library but the issue persists. I copied d3dx9.dll, d3dx9_43.dll and d3dx9d_43.dll to the executable directory which happens to be the same directory as the wrapper DLL. I've verified in the Configuration Manager that Configuration and Platform are the same for all libraries and the executable.

This is my DLL wrapper code. When I comment out DX call, the dll loads with no issue. As soon as I un-comment the Direct3DCreate9() call the incorrect format error appears when it tries to load the dll. The wrapper DLL links with no error. Header file:

#pragma once

namespace ADIVSdll {
    public ref class ADIVSInterop
    {
    public:
        void startLive(System::IntPtr handle);
        void startPlayback(System::String^ str);
    private:
    };
}

Implementation file:

#include "pch.h"
#define _AMD64_
#include "ADIVSdll.h"
#include <wtypes.h>
#include "CppUtil/Logger.h"
#include <../../Microsoft DirectX SDK (June 2010)/include/d3d9.h>

void ADIVSdll::ADIVSInterop::startLive(System::IntPtr handle)
{
    HWND hWnd = (HWND) (long long)handle;
    //IDirect3D9* md3dObject = Direct3DCreate9(D3D_SDK_VERSION);
    Logger::init("log.log");
}

Upvotes: 1

Views: 364

Answers (1)

Rob
Rob

Reputation: 39

No one is probably paying attention to this but here is the answer. Some of my code made a call to D3DXMatrixOrthoLH(). Removing this call caused the error to go away. The only thing I can think of is that somehow it was resolving the method call to an x86 library. It was fairly easy to move over to the newer way of doing things with DirectXMath instead of d3dxmath.

Upvotes: 1

Related Questions