0

I've been working on this project for a while now, its a legacy DLL, my part is to adapt it to work with a new version of a library.

I added a definition to the build defined in the Properties / C/C++ / Preprocessor / Preprocessor Definitions

The definition I added is called CLSOPENLDV and the line looks like this:

    CLSOPENLDV;SP_DEBUG;WIN32;_WINDOWS;_USRDLL;

This use to work and in my code I use the definition to test and switch in and out code:

    #pragma once

    #if defined(CLSOPENLDV) && !defined(CLSOPENLDV_H)
        #define CLSOPENLDV_H
        #pragma comment(lib, "ldv32")
        ...
    #endif

This all use to work, last week I had to switch back to the original build which was a simple case of removing the constant from the properties, however now I want to get back to where I was and for some reason I can't, even though the constant is back in the properties, the preprocessor is not being recognised by the build, the code is grayed in the above #if defined test and I'm really not sure why?

Could it be something to do with pre-compiled headers (pch)?

[Edit] Actually the problem is not exclusive to CLSOPENLDV, the other definition SP_DEBUG isn't making it through to the build either and none of the debug statements included by this definition are enabled.

[Edit2] I've set break points in the debugger and its just not getting to those either, this was all working something is fundamentally broken or disabled.

[Edit3] Its a more fundamental problem than I first thought I cannot debug the project at all...I attach to the Process, but none of my breakpoints are ever hit. I am seeing lots of First-change exceptions in the Output pane but no clue as to where to look as it just gives addresses.

[Edit4] Still trying to figure out whats going on, below is a dump when running the DLL, the only modification I made was to Debug / Exceptions / C++ Exceptions, I checked the Thrown check box, so it now halts with an exception dialog on the first exception:

'Edwards.Scada.AgentService.exe': Loaded 'C:\Program Files\Edwards\Agent Service\Edwards.Scada.AgentService.exe', Binary was not built with debug information. 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\ntdll.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\mscoree.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\kernel32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\KernelBase.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\apphelp.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\apppatch\AcLayers.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\msvcrt.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\user32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\gdi32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\shell32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\cfgmgr32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\windows.storage.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\combase.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\rpcrt4.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\bcryptprimitives.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\advapi32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\sechost.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\shlwapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\kernel.appcore.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\SHCore.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\powrprof.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\profapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\oleaut32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\setupapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\mpr.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\sfc.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\winspool.drv' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\bcrypt.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\sfc_os.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\version.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\msvcr120_clr0400.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib\6457de2c799b00351885b50b15ee8582\mscorlib.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\ole32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System\d07dc4c7e25d0f1f688e96c3651ccbe3\System.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Serv759bfb78#\a8b2254177d41e0ba6c21c1620ad7d05\System.ServiceProcess.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clrjit.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\cryptsp.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\rsaenh.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\cryptbase.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Core\c3edb3947295bb8762d800c029930c15\System.Core.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Configuration\2817463703ac432e3bbf54586b3d6b8b\System.Configuration.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Xml\9d354ba04e2414d763e9dea657f52fff\System.Xml.ni.dll' The thread 'Win32 Thread' (0x2084) has exited with code 0 (0x0). 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4890000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x48b0000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x4890000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Data\e6902bef5b9f4110e975dc92ff87e71d\System.Data.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\Microsoft.NET\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\ws2_32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\crypt32.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\msasn1.dll' First-chance exception at 0x015e401a in Edwards.Scada.AgentService.exe: 0xC0000005: Access violation reading location 0x00000000. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4950000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4960000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x4950000' The thread 'Win32 Thread' (0x25d4) has exited with code 0 (0x0). The thread 'Win32 Thread' (0x13d0) has exited with code 0 (0x0). 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x50a0000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x50f0000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x50a0000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.ServiceModel\dab9738fa2ffd706ad918f4854011580\System.ServiceModel.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Runt73a1fc9d#\0003c5ec8500bfe2571ef6b3768e3327\System.Runtime.Remoting.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\mswsock.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\NapiNSP.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\pnrpnsp.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\nlaapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\winrnr.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\dnsapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\nsi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\rasadhlp.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\IPHLPAPI.DLL' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\FWPUCLNT.DLL' 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4970000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x50e0000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x4970000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\SMDiagnostics\5415baffc9d9111d58c8fe05d4e50c8a\SMDiagnostics.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Servd1dec626#\71634b20929e9a6ed53d7acbffa0b93d\System.ServiceModel.Internals.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x4970000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x5220000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x4970000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Runteb92aa12#\dd6060246740eddfed31aeed179fb81f\System.Runtime.Serialization.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Web.Services\1150e9c52ad5088258dafbd0fce2ae07\System.Web.Services.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x5230000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Loaded 'ImageAtBase0x5280000', No symbols loaded. 'Edwards.Scada.AgentService.exe': Unloaded 'ImageAtBase0x5230000' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Serv14259fd9#\f8ae5cc80236c0593f67d76495fccd46\System.ServiceModel.Activities.ni.dll' First-chance exception at 0x74372ea2 in Edwards.Scada.AgentService.exe: 0xE0434352: 0xe0434352. 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.IdentityModel\43572b8748b627fcbeb032b3656f5810\System.IdentityModel.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Net.Http\f37829993e81bb8c2121b954fda8e480\System.Net.Http.ni.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\httpapi.dll' 'Edwards.Scada.AgentService.exe': Loaded 'C:\Windows\System32\psapi.dll' First-chance exception at 0x74372ea2 in Edwards.Scada.AgentService.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x053dc524..

The first line is very confusing, I've checked the project build several times, it is built for debug.

[Another edit] I've taken the project that was working yesterday from SVN and having completely deleted the existing project, extracted the copy from SVN. I've compiled this and tested, it now crashes where as yesterday it worked, I've re-installed MSVC, installed the service pack and taken a working project and built, but now it doesn't debug and crashes.

Why? What else can I try?

Here is the content of stdafx.h:

#include "stdafx.h"

#ifdef _ATL_STATIC_REGISTRY
    #include <statreg.h>
    #include <statreg.cpp>
#endif

#include <atlimpl.cpp>

Here is the command line from C/C++:

    /Od 
    /I "..\..\..\Legacy Common Files" 
    /I "..\nodetalk2\include"
    /I "..\..\..\..\..\Include" 
    /D "CLSOPENLDV"
    /D "SP_DEBUG"
    /D "WIN32"
    /D "_WINDOWS"
    /D "_USRDLL"
    /D "_VC80_UPGRADE=0x0600"
    /D "_WINDLL" 
    /D "_MBCS"
    /FD /EHsc /MDd /Yc"stdafx.h" 
    /Fp".\Debug/FsLonPlayer.pch"
    /Fo".\Debug/" 
    /Fd".\Debug/" 
    /W4 /nologo /c /Wp64 /Zi /TP /errorReport:prompt

[Edit] The top line of the output is a red herring, it actually is referring to the EXE that this DLL is part of, the DLL is compiled for debug, however having said that it still does not explain why yesterday it was working and I could see source code in the debugger and stop at breakpoints, today I cannot.

20
  • Could this be something to do with pre-compiled headers (pch)? Seems unlikely, but to test this theory simply turn off pch in your project.
    – john
    Jul 17, 2018 at 5:41
  • @john, I wish it was that simple, there are a lot of changes to make in the source as a result of a lot of build errors with the pch turned off.
    – SPlatten
    Jul 17, 2018 at 5:43
  • Sounds like a badly structured project then. If implemented properly pch should be transparent. Maybe your real problem is there.
    – john
    Jul 17, 2018 at 5:45
  • This project is over ten years old, my involvement in it is the last 3 months, it is what it is...
    – SPlatten
    Jul 17, 2018 at 5:47
  • Well sure, but if you fix the problem with pch, so you can turn it on and off at will then maybe this problem will also disappear. Anyway it's hard to advise when I can't see the project.
    – john
    Jul 17, 2018 at 5:50

2 Answers 2

0

Need to move this to an answer for the formatting. I think @ZDF is suggesting you replace the line:

#if defined(CLSOPENLDV) && !defined(CLSOPENLDV_H)

with

#if defined(CLSOPENLDV)

While I'm at it, this next suggestion may not be a long term solution, but it should provide a data point to help figure what's gone wrong. Create a new header file, with just this line in it:

#define CLSOPENLDV

Don't use #include to include it anywhere, instead open the project properties, got to C/C++ -> Advanced and enter the full path to your new header file in the Forced Include File field. Give that a try and see what happens.

Also, another (possibly stupid) idea. Can you pull a version of the project files from your SCM repo as was a week and a half ago when you had this working?

-- Edit --

Just saw your edit to your original post. Did you check the properties for an actual .cpp file, you can do this very easily by viewing the properties for the project itself, verifying that the two definitions are present, and then just clicking on a .cpp file in Solution Explorer. That'll take you to the same property page for the file itself.

I'm highly curious to know what shows there.

13
  • I'm really not with you, changing the #if defined condition doesn't help, the code inside the block is still grayed, which tells me that for some reason the definition "CLSOPENLDV" isn't making it through.
    – SPlatten
    Jul 17, 2018 at 6:32
  • 1
    @SPlatten intellisense is not always working correctly. You'll have to compile.
    – zdf
    Jul 17, 2018 at 6:33
  • @ZDF, thats what I am doing.
    – SPlatten
    Jul 17, 2018 at 6:34
  • @SPlatten Even though it fails, it's a data point that helps. We now know for sure that CLSOPENLDV has gone M.I.A.
    – dgnuff
    Jul 17, 2018 at 6:35
  • It's so frustrating, I'm getting errors for files in the C library that are not part of my build: error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file.
    – SPlatten
    Jul 17, 2018 at 6:36
0

This project is very large and there are multiple sub-projects in the build, it turns out that one of the other projects in the build was causing a problem with my project. Having checked out a much older tree from SVN and built that we can now work out where the faulty project is and fix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.