Trouble Loading a Simconnect DLL from dll.xml

Hi folks,

I wonder if a couple of you wouldn't mind pondering my predicament for a couple minutes, I'd be exceedingly grateful:

When my DLL loads, the sim freezes and never recovers. I get no errors in my simconnect log file. The last message is that the previous dll has loaded successfully.

By now, I have removed all of my real code and am just trying to get the thing to load. When I take away DLLStart or DLLStop, or remove them from the .def file, the sim loads just fine (the dll doesn't, of course), and I get the expected error messages in the simconnect log to the effect that the dll loader can't find DLLStart and DLLStop. But when I do export those functions, I get no error, just a complete freeze.

further notes:
- I've tried the three functions here with all manner of decorations and declspecs (EXTERN_C, WINAPI, declspec(dllExport) and what have you). The behavior is the same. I've tried them void, and as returning int. Same behavior.

- I'm reluctant to suspect that it has anything to do with simconnect itself, as: a) all my other addons load just fine, b) I'm not even attempting to open a client or call any simconnect functions at the moment, and c) I've been developing this project as a gauge loaded from panel.cfg for the past couple weeks and its simconnect client and all its functionality works fine. It's only last night when I tried to switch it to loading from dll.xml (which I'd really like to do) that I get issues.

so has anyone here encountered something similar and licked it?

Thanks so much for taking a look at this, FSDevelopers. Y'all are a bunch of seriously smart people and I'm forever indebted to you.



my main .cpp file, CarrierExtensions.cpp:

#include "gauges.h"

PANELS *Panels;

//The actual DLL entry point. Stores the DLL base address
// hModule = hDLL;
return TRUE;

void DLLStart(void)

void DLLStop(void)

my .def file:

LIBRARY "CarrierExtensions"
Have you tried this style? I did a dll a long time ago and used MFC, but the SDK example is:

// Include files are no different than for an EXE

HANDLE hSimConnect = NULL;

void CALLBACK MyDispatchProcDLL(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
  // Callback code for a DLL is no different than for an EXE

// The DLLStart function must be present.
int __stdcall DLLStart(void)
  if (SUCCEEDED(SimConnect_Open(&hSimConnect, "DLL name", NULL, 0, NULL, 0)))

    // Place all initialization code for the client in this function

    hr = SimConnect_CallDispatch(hSimConnect, MyDispatchProcDLL, NULL);
  return 0;

// The DLLStop function must be present.
void __stdcall DLLStop(void)
  // Close the client
  if (hSimConnect != NULL)
    HRESULT hr = SimConnect_Close(hSimConnect);
Hi Ron,

Thanks so much for your reply.

I tried it with these function signatures and _stdcall specification, and without the DLL main as well, and I get the exact same behavior.

At this point I doubt that the issue is related to what is inside the start/stop functions, as when my debugger is attached, no breakpoints are hit in any of the functions. Something is failing after the Sim reads my exported names, before it successfully calls DLLStart(), and frankly, I'm completely mystified as to what it could be...


Ok, I figured it out:

It was the one thing that I should have expected to fail in between reading the exports and calling the entry function: static object initialization.

Even though I wasn't including any of my header files in the file I included here, the cpp files were still included in the project build. One of my classes has a static std::unique_ptr member, which I was initializing with "new object()". I don't remember what is in that constructor, it worked perfectly when I built it as a gauge. But apparently something in there causes an issue when it loads from dll.xml. I took away the static member, and the dll loads up. Now to add my actual code back in one bit at a time and make sure it all works. I feel pretty stupid for wasting so many hours stumped by this... :(