P3D v4 Update function not called

#1
On to the next topic.
I am trying to export my ship into Prepar3Dv4. Everything works fine, but I have an issue with my DLL. I set up the compiler for 64bit and changed the includes.

When I load up the aircraft in P3D it seems that my DLL file is loaded and the variables are initialized. However my update function is not called.

I am currently using PANEL_SERVICE_PRE_UPDATE to take care of the real-time calculations. Why doesn't this work? o_O
 

ddawson

Resource contributor
#2
The gauge does have to be visible for PANEL_SERVICE_PRE_UDPATE (and POST_UPDATE) to be called.
It doesn't have to stay visible, but it does have to get drawn on the screen at least once.
 
#3
Shoot. That's probably it. How do you know all these things Doug? This is such an obscure piece of information, I can't believe you spot the problem right away! :wizard:

My gauge doesn't have any visual representation, I simply assigned it in the [VCockpit01] section of the panel.cfg - what's a good way to get around that?
 

ddawson

Resource contributor
#4
If the gauge is included in one of the VC sections of panel.cfg, that should be good enough - those are automatically drawn, even if you are not in the VC view.
Have you tried attaching the VS debugger to P3D to see what is going on when the gauge is loaded?
 
#5
No, I haven't managed to get the debugger to work yet. I did a x64 DEBUG build and used "attach to process", selected p3d. I'm not quite sure what I'm doing wrong, but it looks as if nothing happens.
 

n4gix

Resource contributor
#6
Perhaps I'm just peculiar, but all of my "invisible gauges" have at least a 32x32 pix "background" bitmap, and the gauge placement is always 0,0,1,1. This guarantees that it will get 'drawn' albeit on a single pixel... :laughing:
 
#7
Yes, the gauge has one bmp resource, and I use the MAKE_STATIC macro to reference it as well.
I don't know if this helps, but here's the panel.cfg entry:
Code:
[VCockpit01]
file=Panel_L5.bmp
size_mm=512,512
pixel_size=512,512
texture=$NULL
background_color=0,0,0

gauge00=L5_Vega_systems!systems,         20, 20, 40, 40
 

ddawson

Resource contributor
#8
No, I haven't managed to get the debugger to work yet. I did a x64 DEBUG build and used "attach to process", selected p3d. I'm not quite sure what I'm doing wrong, but it looks as if nothing happens.
You will need to make sure you are attempting to debug NATIVE code, and not MANAGED code. I think VS defaults to managed code.
 
#9
I changed from "mixed" to "native". No change :(

Edit:
I've got the Output here, if it helps:
Code:
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\uiInterface.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\MenuSystem.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\LockheedMartin.Controls.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\Views.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\ManagedMirror.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\MenuModels.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\MahApps.Metro.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero2\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero2.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationUI\v4.0_4.0.0.0__31bf3856ad364e35\PresentationUI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXml\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\pc\AppData\Local\Temp\VisualStudio.XamlDiagnostics.18832\WpfXamlDiagnosticsTap.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\assembly\GAC\Microsoft.VisualStudio.OLE.Interop\7.1.40304.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.OLE.Interop.dll'. Module was built without symbols.
The thread 0x7bd0 has exited with code 0 (0x0).
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\UIAutomationProvider\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationProvider.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\Xceed.Wpf.Toolkit.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\QuickGraph.dll'. Module was built without symbols.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\System.Windows.Interactivity.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll'. Cannot find or open the PDB file.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\UIAutomationTypes\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationTypes.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Internals\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Internals.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Lockheed Martin\Prepar3D v4\ConfigParser.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'Microsoft.GeneratedCode'.
'Prepar3D.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'Microsoft.GeneratedCode'.
The thread 0x4cb8 has exited with code 0 (0x0).
The thread 0x6080 has exited with code 0 (0x0).
The thread 0x64a0 has exited with code 0 (0x0).
The thread 0x4ae8 has exited with code 0 (0x0).
 
#10
Vitus,

Am a bit late to the party, but here are three ideas, hopefully one of them turns out to be a good one, and not just stuff you've already tried:
1) Have you tried a simconnect log? It may give you some sort of error that help will shed light on the problem. Take the attached file, change the filepath to your own desired log file location, save the file as "simconnect.ini", and put it in your documents/Prepar3D v4 Files folder. Then start up your sim, let it load up, unload it, and see if the log file tells you anything.

2) The times when I have had this sort of "gauge seems to load and then immediately quits" problem, it's turned out to be that the sim didn't like my static/global variables, or some aspect of their initialization. So if you have anything declared global or static aside from a few pointers or primitive variables, I'd start commenting them out and see if you can hit a breakpoint in your update function. Then think about how to dynamically allocate/initialize the offending objects.

3) A question so we can better understand: if your debugger does not show the DLL as loaded (it should work with "Native" mode selected), on what evidence do you say "it seems that my DLL file is loaded and the variables are initialized"? are these Lvars or Cvars that you are reading through an XML gauge or FSUIPC, or is it something else? Where in your code are these variables being initialized, and what are they being initialized to?

Farley
 

Attachments

DragonflightDesign

Resource contributor
#11
That output indicates that the gauge is loading and unloading correctly ('thread has exited with code 0'). Just to throw mud into the pot, you don't actually need to load a bitmap into the MAKE_STATIC as it will work perfectly well with NULL all through the macro listing. I'm running quite a few system gauges like that. Aaand... I think I may have your answer. I knew I'd been here before: lifted from a thread on Avsim. The respondant is Ed (WarpD).

Posted October 8, 2015

I think I know what it is... give me a minute or two...
Ok... think I got it.


Configuration Properties
C/C++
Code Generation
Runtime Library
Multi-threaded Debug (/MTd)
vs
Multi-threaded Debug DLL (/MDd)
You have Multi-threaded Debug DLL (/MDd) selected for Code Generation. This can add dependencies that may or may not be present at runtime. I've found it's 'best practice' to use Multi-threaded Debug (/MTd) to avoid potential issues.



Ed was right: changing to /MTd made my disappearing gauge appear correctly.
 
#12
That output indicates that the gauge is loading and unloading correctly ('thread has exited with code 0').
To my knowledge, that only indicates that the debugger attached to P3D correctly, not that his DLL loaded correctly. I do not see anything that looks particularly like a gauge in that list of DLLs which DID load.

Edit:
Since this problem came with a new (64bit) build configuration, the Dragonflight/WarpD answer is a very distinct possibility...........
 
#13
Hey guys,

I know that my gauge was initialized because it set some L: vars. One of the first things that happens in the DLL is that it communicates it's version as an L: var that I can read with my XML debug panel. So the gauge definitely loads and initializes some variables. But no update function is ever called.

I changed the compiler settings to MT for my release and MTd for the debug build. And now I'm getting linker errors:
Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in Aircraft.obj L5_Vega_systems C:\Projects\Lockheed Vega\gauge source\l-5_vega\SimConnect.lib(SimConnectClient.obj) 1
What's weird is that the SimConnect.lib file that is referenced here doesn't exist. The first thing I did when starting the p3d conversion was to reorganize the includes and libraries by referencing them in one of my header files:

C++:
#define _64BIT
#ifdef _64BIT
    #include "x64\\gauges.h"
    #include "x64\\SimConnect.h"
    #ifdef _DEBUG
        #pragma comment(lib, "x64\\SimConnectDebug.lib")
    #else
        #pragma comment(lib, "x64\\SimConnect.lib")
    #endif
    #define PUSERDATA UINT_PTR
#else
    #include "x32\\gauges.h"
    #include "x32\\SimConnect.h"
    #pragma comment(lib, "x32\\SimConnect.lib")
    #define PUSERDATA UINT32
#endif
As you can see, the SimConnect.lib file is either in the x32 or the x64 folder.

I'm really puzzled. o_O
 

ddawson

Resource contributor
#14
Check the linker options in Solution Explorer. Given your #pragma comment entries, you need to make sure you don't have SimConnect referenced in the Input options.
 
#15
I deleted all references to any SimConnect files from the project's options when I switched to the handy #pragma statements. I also went through all of the settings over and over again, I can't find a single reference to simConnect in any of the options...
This is so weird...

linker.jpg
 

ddawson

Resource contributor
#16
Where are you loading the gauge from?
If you're using the panel folder, make sure you don't have an older version of the gauge in the main gauges folder.
 
#17
I compile directly into the panel folder of my aircraft. I checked and double checked, there's no other version of this gauge anywhere. The Linker still tried to find the simConnect.lib in my project folder where there isn't any file of that name.
 
#18
I believe the reason the linker is searching for the .lib file in your project folder is because that's the default search location. It's not seeing anywhere else to look would be my guess.
 
#20
Hey guys,

I believe I have a solution for my problem. I started a new project in VS and set it up for 32 bit and 64 bit gauge compilation. Added an execute_calculator_code inside the PANEL_SERVICE_PRE_UPDATE that sets a test variable to "1" and tadaaaaaa: it works.

So now I only have to re-import all these tons of code of my previous gauge and I should be set.... I'll let you know if it doesn't work out :duck:
 
Top