• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Simconnect program as DLL

Messages
4
Hi, I have tried to deploy a simconnect program written in c# as dll but I
should be missing the point.

Simconnect log says:

57.57868 DLL Start Proc not found: StartProc="DLLStart" Path="TestDLL.dll"
57.57871 DLL Stop Proc not found: StopProc="DLLStop" Path="TestDLL.dll"
57.57875 DLL Load Failed: Error=-2 Path="TestDLL.dll"

And the dll is as simple as:
Code:
namespace TestDLL
{
    public class Class1
    {
        public static int DLLStart()
        {
            return 0;
        }
        public static void DLLStop()
        {
        }
    }
}

Any ideas about what is wrong?

Thanks in advance
 
You may have covered this already but as I only build exe's im not sure about the errors you are getting.. but looking through the simconnect docs there was a section on dll requirements

Code:
Create and add a definition file to the project. This is needed because SimConnect expects the exported names DLLStart and DLLStop to be undecorated (by default additional characters are added to these names). The definition file can be created by selecting Project/Add New Item from the main menu in Visual Studio. Edit the definition (.def) file so it looks like this (where DLL Project is the name of your project):

Did you follow these instructions before you run your code? If so - sorry Im not too sure what this could be

Hope this helps

Dave
 
Well, the missed point is that FSX is unmanaged code and your dll is managed.

What you are trying to do is possible but a total mess. You cannot do it directly from VS. It involves some manual dll editing and a good knowlodge of IL. I did some concept experiments (with success) but I ended totally fed up with the FSX security warnings each time I modified a bit.

Also, it is not difficult "to close" FSX with this kind of things. I did it several times :D :(

So, now I am in the exe world. Maybe when finished and debugged I'll come back to dll as it has some advantages.

Best Regards,
Javier.
 
I managed to load a managed dll (VB) in FSX and basically used this approach:

I wrote a wrapper dll in unmanaged C++ containing the necessary DLLStart() and DLLStop() functions. Inside these functions i called via a COM interface exported DLLStart() and DLLStop() methods inside the managed DLL and could create a simconnect connection. Basically i did what is described in MSDN about calling managed code from unmanaged C++.

BUT:

My managed code contained some logging functions but all i saw in the log was the first line written, anything else was not written although the system.io.streamwriter was set to autoflush and i explicitely flushed after every message. Experimented a lot. Also test message boxes didn't show up etc.
So something doesn't get initialized correctly in the CLR or for the CLR, not sure. My guess is that the addon dll is running in it's own thread and that thread has no windows message queue associated or something along that line, thus windows stuff doesn't work. Or maybe its something completely different, dunno.

But since i went that far to write a C++ dll, i will implement that little bit that i need to be executed directly in FS in this C++ dll (mostly dialog stuff) and implment the rest in standalone managed exes which use simconnect to talk to my C++ dll too.
 
That is the normal way to export managed code that will be used from unmanaged code but I tried another approach.

To keep it simple, I have a standard managed dll solution with a DLLStart() that just has a "xx=new Form()", my main form. It is showed only when called from menu.

The rest of the program is the same managed code than I would have as an exe solution so I can test it easily.

The trick is to create manually the vtables needed and to export DLLStart and DLLStop as unmanaged code.

Best Regards,
Javier.
 
SimConnect DLL Configuration

Trying to create a SimConnect DLL Project (MySimConnect). I created the .def file as specified in the sdk.

LIBRARY "SimConnect"
EXPORTS
DLLStart
DLLStop

Added the .def file to my project property, still getting the following when I start FSX:

DLL Start Proc not found: StartProc="<my path>/MySimConnect.dll".
DLL Stop Proc not found: StopProc="<my path>/MySimConnect.dll".

Same result if I change the exported names (DLLStart/Stop) to a valid functions within the SimConnect.lib library

Am I missing a step? Also, note that I'm using c++.

Thanks
 
Last edited:
When I create a dll - the LIBRARY is the name of my program/dll. You used "simconnect". Try "yourprogdll" - what ever you named you program. Reread the SDK. :D
 
Last edited:
Hey Geoff,

Did that sample require anything other than changing the include file directory reference and the reference to the SimConnect.lib from the ESP SDK directories to the FSX SDK directories? I tried to write it so it would work with either :->

That sample shows how we expected in-proc DLL based SimConnect clients to behave - ie no Win32/GDI/etc UI used. If you want to display a standard UI, the expectation was that those would be out-of-proc external EXE based clients (which also have the ability, at least with ESP or the Deluxe version of FSX, of being run on a seperate networked machine).
 
Hey Geoff,

Did that sample require anything other than changing the include file directory reference and the reference to the SimConnect.lib from the ESP SDK directories to the FSX SDK directories? I tried to write it so it would work with either :->

That sample shows how we expected in-proc DLL based SimConnect clients to behave - ie no Win32/GDI/etc UI used. If you want to display a standard UI, the expectation was that those would be out-of-proc external EXE based clients (which also have the ability, at least with ESP or the Deluxe version of FSX, of being run on a seperate networked machine).

lol Good Question -- yes, I changed the SimConnect.lib reference, and then it compiled. However, when I tried to run FSX with tha dll included, none of my addon dll's ran.
Not had time to debug to figure out why yet.
( should have worked ! )
 
Probably a minor typo in the DLL.XML file, would be my first guess :->


OMG !! You are good ... Exactly Correct -- Typo.:wizard:

So, it runs fine in FSX SP2 :)

Looking at it did raise another question, to do with Metar Strings.

How does one define what units the Metar parameters are returned ?

ie
ALTIMETER One of:

ANNNN - altimeter in degrees of mercury (for example, A2992)

QNNNN - altimeter in millibars


It defaults to QNNNN, despite the sim being set to use ANNNN.

( International Units of Measure: US System (feet, inches)
 
Hey Geoff,

SimConnect will only return the Qnnnn format for a Metar string. If you are setting a weather observation via SimConnect, then it will accept either format for the Pressure value, but it only returns the one format.
 
Hey Geoff,

SimConnect will only return the Qnnnn format for a Metar string. If you are setting a weather observation via SimConnect, then it will accept either format for the Pressure value, but it only returns the one format.

Tim, thanks for confirming that .. did not catch that in the SDK, which did show the various Metar formats, but did not indicate how to control which one gets returned.

So, to get say a US formatted metar, one has to parse the returned string and do the necessary conversions :( ( and really make it a real world Metar, as opposed to one formatted with the Microsoft FS format )

At least I know now I would have to do that, and will not waste time writting such conversions, only to be told there was a way already built into the SDK :)
 
Back
Top