FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Access Violation Error on CreateActivex - Solved
Posts: 114
Joined: Fri Jul 21, 2006 07:15 PM
Access Violation Error on CreateActivex - Solved
Posted: Fri Dec 19, 2025 12:25 PM

Hello everyone.

When I compile with the Visual Studio IDE, in debug mode, when viewing an HTML file using the TActiveX class, I'm getting an error that generates a log like the one below: (hb_out.log)

Application Internal Error - D:\Softway\CratusERP_MSVC\CratusERP.exe
Terminated at: 2025-12-13 18:30:20
Erro irrecuper vel 6005: Exception error:

Exception Code:C0000005 ACCESS_VIOLATION
Exception Address:681ECB3C
EAX:00000044  EBX:006659EC  ECX:00000044  EDX:00000000
ESI:00000000  EDI:01892178  EBP:00665930
CS:EIP:0023:681ECB3C  SS:ESP:002B:00665928
DS:002B  ES:002B  FS:0053  GS:002B
Flags:00010246
Exception Parameters: 00000000 00000044
CS:EIP: 0F B6 08 85 C9 74 02 EB D4 8B 45 FC 2B 45 08 8B
SS:ESP: 00000060 00000044 006659E0 681ECFF1 00000044 0000001C FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE

C stack:
EIP:     EBP:       Frame: OldEBP, RetAddr, Params...
681ECB3C 00665930   006659E0 681ECFF1 00000044 0000001C FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE
681ECFF1 006659E0   006659FC 681EC9FB 00665A2C 015633AC 681EC9FB 00000044 7FFFFFFF
681EC9FB 006659FC   00665A0C 681ED8F2 00000044 7FFFFFFF
681ED8F2 00665A0C   00665A20 681369D9 00000044 7FFFFFFF 00665B00
681369D9 00665A20   00665A3C 68135CBF 7FFFFFFF 00000000 7FFFFFFF 7FFFFFFF 00665B00
68135CBF 00665A3C   00665A64 681D6812 00000008 681233A8 00000032 0066B130 00665B00 FFFFFFFF 00665A94 00665B00
681D6812 00665A64   00665A94 681CFF9E 00665A90 00666010 00665F48 00000007 00665F5C 681C162B 00000001 00000001
681CFF9E 00665A94   00665F5C 681C1636 00665AEC FEFEFEFE FEFEFEFE FEFEFEFE FEFEFEFE 00000000 00000000 FEFEFEFE
681C1636 00665F5C   00665FE8 681C0CE7 00000000 00000000 00668124 00000FEC 680E9BD8 00666010 0066B188 00666028
681C0CE7 00665FE8   0066603C 681E0829 00000000 00000000 00668124 00001000 00000FEB 680E9BD8 00666010 0066B188
681E0829 0066603C   0066606C 681A2301 00000000 00000000 00668124 00001000 00000FEB 680E9BD8 00000000 0066B188
681A2301 0066606C   0066608C 681A22C0 00668124 00001000 00000FEB 680E9BD8 00000000 0066B188
681A22C0 0066608C   0066B140 681A112A 00668124 00001000 00000FEB 680E9BD8 0066B188 10523267 01892178 00000000
681A112A 0066B140   0066B16C 681A0B0F 00000001 6818F361 00000000 00000000 00000000 680E9BD8 0066B188 0000038C
681A0B0F 0066B16C   0066B200 6818F361 00000001 00000000 00000000 00000000 680E9BD8 680E9624 A791FD7B 01EEBD90
6818F361 0066B200   0066B240 6818E10C 01EEBD90 00000000 10523167 01892178 00000000 015633AC 00000000 00000000
6818E10C 0066B240   0066B250 00BAA36E 01EEBD90 FFFFFFFF
00BAA36E 0066B250   0066B25C 00BA738C 01EEBD90
00BA738C 0066B25C   0066B290 009A2FDF 01EEBD90 01EEBD90 01EEBD90 0066B27C 009A413F 01EE5690 8856F961 11D0340A
009A2FDF 0066B290   0066B2A8 009A377F 013F29D0 01EE5690 01EE5690 01EE5690
Modules:
00700000 01343000 D:\Softway\CratusERP_MSVC\CratusERP.exe
773E0000 001AA000 C:\WINDOWS\SYSTEM32\ntdll.dll
75140000 000F0000 C:\WINDOWS\System32\KERNEL32.DLL
76DB0000 00261000 C:\WINDOWS\System32\KERNELBASE.dll
75080000 000A2000 C:\WINDOWS\SYSTEM32\apphelp.dll
67070000 002CA000 D:\Softway\CratusERP_MSVC\LIBMYSQL.dll
76AE0000 00112000 C:\WINDOWS\System32\ucrtbase.dll
73830000 00223000 C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.22000.120_none_e541a94fcce8ed6d\COMCTL32.dll
736A0000 0016B000 C:\WINDOWS\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.22000.2003_none_93fcfb98d9f1057f\gdiplus.dll
75960000 00064000 C:\WINDOWS\System32\WS2_32.dll
77300000 000C2000 C:\WINDOWS\System32\msvcrt.dll
76200000 000BC000 C:\WINDOWS\System32\RPCRT4.dll
771F0000 00023000 C:\WINDOWS\System32\GDI32.dll
75BE0000 0028A000 C:\WINDOWS\System32\combase.dll
76C00000 001AC000 C:\WINDOWS\System32\USER32.dll
76320000 0001A000 C:\WINDOWS\System32\win32u.dll
77020000 0007C000 C:\WINDOWS\System32\ADVAPI32.dll
75A00000 000E9000 C:\WINDOWS\System32\gdi32full.dll
77220000 000BF000 C:\WINDOWS\System32\COMDLG32.dll
75EF0000 0007B000 C:\WINDOWS\System32\msvcp_win.dll
73470000 00024000 C:\WINDOWS\SYSTEM32\IPHLPAPI.DLL
75E70000 0007A000 C:\WINDOWS\System32\sechost.dll
76000000 000C1000 C:\WINDOWS\System32\shcore.dll
696B0000 00019000 C:\WINDOWS\SYSTEM32\MPR.dll
73340000 00006000 C:\WINDOWS\SYSTEM32\MSIMG32.dll
75B90000 0004A000 C:\WINDOWS\System32\SHLWAPI.dll
73310000 0002E000 C:\WINDOWS\SYSTEM32\oledlg.dll
71280000 00008000 C:\WINDOWS\SYSTEM32\VERSION.dll
770A0000 0014E000 C:\WINDOWS\System32\ole32.dll
764B0000 00616000 C:\WINDOWS\System32\SHELL32.dll
68CF0000 00031000 C:\WINDOWS\SYSTEM32\WINMM.dll
75AF0000 0009C000 C:\WINDOWS\System32\OLEAUT32.dll
68D80000 0001F000 C:\WINDOWS\SYSTEM32\VCRUNTIME140D.dll
680E0000 0019F000 C:\WINDOWS\SYSTEM32\ucrtbased.dll
68C70000 00079000 C:\WINDOWS\SYSTEM32\WINSPOOL.DRV
759D0000 00025000 C:\WINDOWS\System32\IMM32.DLL
6E9B0000 00082000 C:\WINDOWS\system32\uxtheme.dll
5F000000 00011000 C:\WINDOWS\SYSTEM32\CTL3D32.DLL
75880000 000DA000 C:\WINDOWS\System32\MSCTF.dll
66C50000 00415000 D:\Softway\CratusERP_MSVC\Dll\SW.DLL
74FB0000 00012000 C:\WINDOWS\SYSTEM32\kernel.appcore.dll
75230000 00064000 C:\WINDOWS\System32\bcryptPrimitives.dll
69800000 000E2000 C:\WINDOWS\SYSTEM32\textinputframework.dll
69060000 000CB000 C:\WINDOWS\SYSTEM32\CoreMessaging.dll
68930000 00293000 C:\WINDOWS\SYSTEM32\CoreUIComponents.dll
72AF0000 000EB000 C:\WINDOWS\SYSTEM32\wintypes.dll
711C0000 0000B000 C:\WINDOWS\SYSTEM32\CRYPTBASE.DLL
69990000 00096000 C:\WINDOWS\SYSTEM32\TextShaping.dll
73350000 00025000 C:\WINDOWS\SYSTEM32\SspiCli.dll
70000000 00012000 C:\WINDOWS\system32\napinsp.dll
6FFE0000 00016000 C:\WINDOWS\system32\pnrpnsp.dll
70020000 00050000 C:\WINDOWS\System32\mswsock.dll
711D0000 000AF000 C:\WINDOWS\SYSTEM32\DNSAPI.dll
75870000 00007000 C:\WINDOWS\System32\NSI.dll
6FF90000 0000E000 C:\WINDOWS\System32\winrnr.dll
6FF70000 00011000 C:\WINDOWS\system32\wshbth.dll
6FF50000 00019000 C:\WINDOWS\system32\nlansp_c.dll
6FEE0000 00008000 C:\Windows\System32\rasadhlp.dll
757E0000 00082000 C:\WINDOWS\System32\clbcatq.dll

Called from CREATEACTIVEX(0)
Called from TACTIVEX:NEW(87) in .\source\classes\activex.prg
Called from SHOWHTML:EXECUTE(123) in .\Source\ShowHtml.prg
Called from _IMPRIMEVISUALIZA(4048) in D:\Softway\CratusERP_MSVC\Source\FATLAN01.PRG
Called from _SELECTPRINT(3459) in D:\Softway\CratusERP_MSVC\Source\FATLAN01.PRG
Called from (b)FATLAN01(217) in D:\Softway\CratusERP_MSVC\Source\FATLAN01.PRG
Called from TBUTTONBMP:CLICK(193) in .\source\classes\button.prg
Called from TBUTTON:HANDLEEVENT(1831) in .\source\classes\control.prg
Called from TBUTTONBMP:HANDLEEVENT(260) in .\source\classes\buttonb.prg
Called from _FWH(3760) in .\source\classes\window.prg
Called from SENDMESSAGE(0)
Called from TDIALOG:COMMAND(518) in .\source\classes\dialog.prg
Called from TWINDOW:HANDLEEVENT(0)
Called from TDIALOG:HANDLEEVENT(1257) in .\source\classes\dialog.prg
Called from DIALOGBOXINDIRECT(0)
Called from TDIALOG:ACTIVATE(325) in .\source\classes\dialog.prg
Called from ACTIVE(27) in .\Source\ACTIVE.prg
Called from FATLAN01(230) in D:\Softway\CratusERP_MSVC\Source\FATLAN01.PRG
Called from (b)_EXECUTE(68) in D:\Softway\CratusERP_MSVC\Source\CONFIG04.prg
Called from _EXECUTE(70) in D:\Softway\CratusERP_MSVC\Source\CONFIG04.prg
Called from (b)CONFIG04_EXEC(47) in D:\Softway\CratusERP_MSVC\Source\CONFIG04.prg
Called from TBUTTONBMP:CLICK(193) in .\source\classes\button.prg
Called from TBUTTON:HANDLEEVENT(1831) in .\source\classes\control.prg
Called from TBUTTONBMP:HANDLEEVENT(260) in .\source\classes\buttonb.prg
Called from _FWH(3760) in .\source\classes\window.prg
Called from SENDMESSAGE(0)
Called from TDIALOG:COMMAND(518) in .\source\classes\dialog.prg
Called from TWINDOW:HANDLEEVENT(0)
Called from TDIALOG:HANDLEEVENT(1257) in .\source\classes\dialog.prg
Called from DIALOGBOXINDIRECT(0)
Called from TDIALOG:ACTIVATE(325) in .\source\classes\dialog.prg
Called from ACTIVE(27) in .\Source\ACTIVE.prg
Called from CONFIG04_EXEC(51) in D:\Softway\CratusERP_MSVC\Source\CONFIG04.prg
Called from _CHECKSTART(126) in D:\Softway\CratusERP_MSVC\Source\MAIN.PRG
Called from (b)MAIN(92) in D:\Softway\CratusERP_MSVC\Source\MAIN.PRG
Called from _BUILDMAIN(115) in .\Source\ACTIVE.prg
Called from (b)ACTIVE(20) in .\Source\ACTIVE.prg
Called from TWINDOW:ACTIVATE(1156) in .\source\classes\window.prg
Called from ACTIVE(20) in .\Source\ACTIVE.prg
Called from MAIN(97) in D:\Softway\CratusERP_MSVC\Source\MAIN.PRG

But, when I compile with dos prompt, by "build.bat" (release version) it works fine, as always does.
This problem started when I try to use FWH2509 version, and reconfigured MSVC Ide to that version.
I am using the sames libs in file .mak and the Ide of MSVC.
Can be something lib of Microsoft C that be need different?
Tools: MSVC 17.14.19, Harbour 3.2.0dev (r2503251254), FWH2509.
Thanks all.

FWH / xHarbour / BCC / MySql

Visual Studio / Harbour / DotNet Maui / C#
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Access Violation Error on CreateActivex
Posted: Fri Dec 19, 2025 12:32 PM

This is a classic and frustrating scenario: the application works perfectly in Release mode (via build.bat) but crashes in Debug mode (Visual Studio IDE).

Based on the crash log and the context (FWH2509 + MSVC), the issue is almost certainly a C Runtime Library (CRT) Mismatch.

The Diagnosis

Visual Studio's "Debug" mode defaults to linking against the Debug Runtime Libraries (/MDd), which use VCRUNTIME140D.dll and ucrtbased.dll.

However, the Harbour and FiveWin libraries (fiveh.lib, harbour.lib, etc.) are typically compiled in Release mode (/MD), linking against VCRUNTIME140.dll (no "D").

When you mix these two (Debug CRT for your app vs. Release CRT for FiveWin), they use different memory heaps. When TActiveX (which relies heavily on COM and OLE) tries to pass memory or window handles between your app and the FiveWin internal C code, the mismatch triggers an ACCESS_VIOLATION (C0000005).

The Solution

You need to force your Visual Studio Debug configuration to use the Release Runtime Library, even though you are debugging.

Here is how to fix it in the Visual Studio IDE:

  1. Open Project Properties:
    Right-click your Project in the Solution Explorer and select Properties.
  2. Select Configuration:
    At the top left, ensure Configuration is set to Debug (or "All Configurations" if you want this to apply globally).
  3. Change Code Generation:
  4. Navigate to Configuration Properties > C/C++ > Code Generation.
  5. Look for the Runtime Library setting.
  6. It is likely set to Multi-threaded Debug DLL (/MDd).
  7. Change this to Multi-threaded DLL (/MD).
  1. Apply and Rebuild:
    Click Apply, then OK. Then perform a Clean Solution and Rebuild Solution.

Why did this happen now?

You mentioned this started with FWH 2509. Newer versions of FiveWin and Harbour built with recent MSVC compilers are strictly aligned with standard memory allocators. Earlier versions might have been more forgiving, or your previous MSVC setup might have accidentally matched the runtimes.

Secondary Check: Linker Dependencies

If the above does not resolve the crash immediately, verify that you are linking the necessary OLE libraries in your Visual Studio project settings (since build.bat might be including them automatically):

  1. Go to Properties > Linker > Input.
  2. Ensure the following are present in Additional Dependencies:
  3. oledlg.lib
  4. mfcs140.lib (rarely needed but check if FWH requires it)
  5. Crucially: gdiplus.lib (ActiveX in FWH often needs this initialized correctly)

Summary of the Fix

By changing /MDd to /MD, you align your application's memory manager with the one inside fiveh.lib. You can still debug your own PRG/C code (breakpoints, variables), but you won't get deep debug inspection into the Microsoft C runtime functions themselves—which is usually acceptable.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 114
Joined: Fri Jul 21, 2006 07:15 PM
Re: Access Violation Error on CreateActivex
Posted: Sat Dec 20, 2025 01:42 PM

Antonio, Thanks for the answer, but this solution does not be able to generate the exe because it gets 1996 link errors. I also try to solve these errors by my self using AI help but no success too. I reverted to the previous configuration to continue my work and will investigate further later. I believe it might be some new library introduced in FWH2509 (buildh32.bat) used in my .mak file, which in MSVC require other equivalents. As I mentioned before, I'm using the same libraries from the .mak file (mentioned in buildh32.bat) for the MSVS IDE environment. This approach is probably incorrect.

Regards.

FWH / xHarbour / BCC / MySql

Visual Studio / Harbour / DotNet Maui / C#
Posts: 114
Joined: Fri Jul 21, 2006 07:15 PM
Re: Access Violation Error on CreateActivex - Solved
Posted: Tue Jan 13, 2026 07:56 PM

About this problem and to who is interested.

I replaced lib "ucrt.lib" by "ucrtd.lib" in the Visual Studio linker script and worked fine.

Regards.

FWH / xHarbour / BCC / MySql

Visual Studio / Harbour / DotNet Maui / C#

Continue the discussion