Recent

Author Topic: application could not be started correctly (0xc000007)  (Read 630 times)

Weitentaaal

  • Jr. Member
  • **
  • Posts: 56
application could not be started correctly (0xc000007)
« on: October 27, 2020, 04:53:02 pm »
Hey Guys,

So in my Project im Getting this Error Message(Caption of Topic) when after kompiling. The kompiling was Succsessfull.
I think its because of my sqlite.dll. I Have no clue about 64 Bit dll's and 32 Bit dll's and where they are installed or just how to fix this error.

Thanks for Help ::)

Weitentaaal

  • Jr. Member
  • **
  • Posts: 56
Re: application could not be started correctly (0xc000007)
« Reply #1 on: October 27, 2020, 04:55:09 pm »
Version 2.0.6
FPC version 3.0.4
x86_64-win64-win32/win64

440bx

  • Hero Member
  • *****
  • Posts: 2047
Re: application could not be started correctly (0xc000007)
« Reply #2 on: October 27, 2020, 07:58:59 pm »
error 0xC000 0007 (STATUS_PAGEFILE_QUOTA) is reported by Windows usually when it encounters a problem related to page file usage.  Most common problem is to run out of space in the page file.  This could be a result of using a fixed page file size or an extensible page file on a drive that has run out of space.  Those are not the only two reasons, other reasons related to the page file are possible.

your first step should be to check your page file usage and accessibility.

HTH.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Weitentaaal

  • Jr. Member
  • **
  • Posts: 56
Re: application could not be started correctly (0xc000007)
« Reply #3 on: October 28, 2020, 01:54:08 pm »
So i wrote a little Test Programm just to see if it works with my external dll. Error was no more but it was very weird

Code:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   sqldb,  SQLite3Conn, DB;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27.   Procedure dbExecute(var Recordset: TSQLQuery; Query: String); external 'networkdb.dll';
  28.   Procedure initNetworkDB(MacAdresse, pathToWGR: String; ZeichnungsNr: Integer; DATABASE_MODE: Integer = 2);external 'networkdb.dll';
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure TForm1.Button1Click(Sender: TObject);
  37. var
  38.   dbT: TSQLQuery;
  39. begin
  40.   ShowMessage('Before dll');
  41.   initNetworkDB('rand','C:\WGKBlck\Data\', 1, 2);
  42.   ShowMessage('t1');
  43.   dbT := TSQLQuery.Create(nil);
  44.   showMessage('t2');
  45.   showMessage('t3');
  46.   dbExecute(dbT ,'SELECT * FROM Plattentauscher');
  47.   ShowMessage('t4');
  48.  
  49.   ShowMessage(dbT.FieldByName('INDEX').Text);
  50.  
  51.   dbT.Free;
  52. end;
  53. end.
  54.  

it just came until ShowMessage('t3'); and after that came nothing anymore... not even an error and there are no endless code blocks
Dll Code :

Code: Pascal  [Select][+][-]
  1. library NetworkDB;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   SysUtils, StrUtils, odbcconn, WinINet, Math, SQLite3Conn, Classes, sqldb, db, Dialogs;
  7.  
  8. type
  9.   BBWeb = record
  10.       S01, S02, S03, S04, S05, S06, S07, S08, S09, S10, S11, S12, S13, S14, S15, S16, S17, S18, S19, S20, S21, S22, S23, S24, S25: String;
  11.       S26, S27, S28, S29, S30, S31, S32, S33, S34, S35, S36, S37, S38, S39, S40, S41, S42, S43, S44, S45, S46, S47, S48, S49, S50: String;
  12.       R01, R02, R03, R04, R05, R06, R07, R08, R09, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25: String;
  13.       R26, R27, R28, R29, R30, R31, R32, R33, R34, R35, R36, R37, R38, R39, R40, R41, R42, R43, R44, R45, R46, R47, R48, R49, R50: String;
  14.       RML: String;
  15.   end;
  16.  
  17.   LicenseVar = record
  18.     Is3d, Sound, Regis, SysView, EnabMod, TimStamp, ShFact, AlowModfy, PrxStat, PrxCop, SecNumber1, SecNumber2, OwnPick: Integer;
  19.     MacAd, Cntry, Firma, FUser, SVers, BBSrvIP1, BBSrvIP2: String;
  20.     MFak, SteuFak: Single;
  21.     OpenDim: Boolean;
  22.   End;
  23.  
  24.   IpVar = record
  25.     Byt1, Byt2, Byt3, Byt4: Integer;
  26.   End;
  27.  
  28. var
  29.   MAC, WGRPath: String;
  30.   DB_MODE, ZeichNr: Integer;
  31.   mdbConn, mdbWGR: TSQLite3Connection;
  32.   sqlConnWGR, sqlConnWSET, sqlConnDEF: TSQLite3Connection;
  33.   SQLTransWGR, SQLTransWSET, SQLTransDEF: TSQLTransaction;
  34.  
  35. const
  36.   { ----- constants ----- }
  37.   BBWebAdresse = 'http://80.247.70.137/'; //oder 'http://80.247.70.136/'
  38.   LicUrl = 'http://wgk.weger.it';
  39.  
  40.   MDBPath = 'C:\WGKBlck\Data\wegerset.mdb';
  41.   MDBPass = '260599';
  42.  
  43.   WGRPass = 'wgkadmin';
  44.  
  45.   SQLiteWGRPath = 'C:\WGKBlck\Data\Noname.db';
  46.   SQLiteWGRPass = 'wgkadmin';
  47.  
  48.   SQLiteWSETPath = 'C:\WGKBlck\Data\wegerset.db';
  49.   SQLiteWSETPass = '260599';
  50.  
  51.   SQLiteDEFPath = 'C:\WGKBlck\Data\Definitionen.db';
  52.  
  53. { ----- initialisation ----- }
  54. Procedure initdb(MODE: Integer);
  55. Begin //Datenbank initialisieren
  56.   DB_MODE := MODE;
  57.   Case DB_MODE Of //Verbindungstyp wählen (MSAccess oder SQLite)
  58.     1:
  59.       Begin
  60.         {mdbConn := TODBCConnection.Create(Nil);
  61.         mdbConn.Driver := 'Microsoft Access Driver (*.mdb)';
  62.         mdbConn.Params.add('DBQ=' + MDBPath);
  63.         mdbConn.Params.add('pwd=' + MDBPass);
  64.         mdbConn.Connected := true;
  65.         mdbConn.KeepConnection := true;
  66.         TSQLTransaction.Create(Nil).DataBase := mdbConn;
  67.  
  68.         mdbWGR := TODBCConnection.Create(Nil);
  69.         mdbWGR.Driver := 'Microsoft Access Driver (*.mdb)';
  70.         mdbWGR.Params.add('DBQ=' + WGRPath);
  71.         mdbWGR.Params.add('pwd=' + WGRPass);
  72.         mdbWGR.Connected := true;
  73.         mdbWGR.KeepConnection := true;
  74.         TSQLTransaction.Create(Nil).Database := mdbWGR;}
  75.       End;
  76.     2:
  77.       Begin
  78.         Try
  79.            Applicatio.i;
  80.            { ----- WGR Connect ----- }
  81.            sqlConnWGR := TSQLite3Connection.Create(Nil);
  82.            sqlConnWGR.DatabaseName := SQLiteWGRPath;
  83.            //sqlConnWGR.HostName := SQLiteDBHost;
  84.            //sqlConnWGR.UserName := SQLiteDBUser;
  85.            sqlConnWGR.Password := SQLiteWGRPass;
  86.            sqlConnWGR.Connected := true;
  87.            sqlConnWGR.KeepConnection := true;
  88.  
  89.            SQLTransWGR := TSQLTransaction.Create(sqlConnWGR);
  90.            sqlConnWGR.Transaction := SQLTransWGR;
  91.  
  92.            { ----- WSET Connect ----- }
  93.            sqlConnWSET := TSQLite3Connection.Create(Nil);
  94.            sqlConnWSET.DatabaseName := SQLiteWSETPath;
  95.            //sqlConnWSET.HostName := SQLiteDBHost;
  96.            //sqlConnWSET.UserName := SQLiteDBUser;
  97.            sqlConnWSET.Password := SQLiteWSETPass;
  98.            sqlConnWSET.Connected := true;
  99.            sqlConnWSET.KeepConnection := true;
  100.  
  101.            SQLTransWSET := TSQLTransaction.Create(sqlConnWSET);
  102.            sqlConnWSET.Transaction := SQLTransWSET;
  103.  
  104.            { ----- DEF Connect ----- }
  105.            sqlConnDEF := TSQLite3Connection.Create(Nil);
  106.            sqlConnDEF.DatabaseName := SQLiteDEFPath;
  107.            //sqlConnDEF.HostName := SQLiteDBHost;
  108.            //sqlConnDEF.UserName := SQLiteDBUser;
  109.            //sqlConnDEF.Password := SQLiteWSETPass;
  110.            sqlConnDEF.Connected := true;
  111.            sqlConnDEF.KeepConnection := true;
  112.  
  113.            SQLTransDEF := TSQLTransaction.Create(sqlConnDEF);
  114.            sqlConnDEF.Transaction := SQLTransDEF;
  115.            except
  116.               //on e:exception do //TODO
  117.            end;
  118.       End;
  119.     Else Exit();
  120.   End;
  121. End;
  122.  
  123. Procedure initNetworkDB(MacAdresse, pathToWGR: String; ZeichnungsNr: Integer; DATABASE_MODE: Integer = 2);
  124. Begin
  125.   ShowMessage('initNetworkDb()');
  126.   MAC := MacAdresse;
  127.   ZeichNr := ZeichnungsNr;
  128.   WGRPath := pathToWGR;
  129.   initdb(DATABASE_MODE);
  130. End;
  131.  
  132. Procedure exitNetworkDB();
  133. Begin
  134.   Case DB_MODE Of
  135.     1:
  136.       begin
  137.         mdbConn.Close();
  138.         mdbconn.CloseDataSets;
  139.         mdbWGR.Close();
  140.         mdbWGR.CloseDataSets;
  141.       end;
  142.     2: begin
  143.        sqlConnDEF.Close();
  144.        sqlConnWGR.Close();
  145.        sqlConnWSET.Close();
  146.        SQLTransDEF.CloseDataSets;
  147.        SQLTransWGR.CloseDataSets;
  148.        SQLTransWSET.CloseDataSets;
  149.     end;
  150.   End;
  151. End;
  152.  
  153. { ----- implementation ---- }
  154. Procedure dbExecute(var Recordset: TSQLQuery; Query: String); //TSQLQuery entspricht VB6 Recordset (fast)
  155. Begin
  156.   Recordset.Free;
  157.   Recordset := TSQLQuery.Create(nil);
  158.   Case DB_MODE Of
  159.     1: Recordset.DataBase := mdbConn;
  160.     2: Recordset.DataBase := sqlConnWSET;
  161.   End;
  162.   Recordset.UsePrimaryKeyAsKey := False;
  163.   Recordset.PacketRecords := -1;
  164.   Recordset.SQL.Text := Query;
  165.   Recordset.Open;
  166. End;
  167.  
  168. Procedure wgrExecute(var Recordset: TSQLQuery; Query: String);
  169. Begin
  170.   Recordset.Free;
  171.   Recordset := TSQLQuery.Create(nil);
  172.   Recordset.UsePrimaryKeyAsKey := False;
  173.   Case DB_MODE Of
  174.      1: Recordset.DataBase := mdbWGR;
  175.      2: Recordset.DataBase := sqlConnWGR;
  176.   End;
  177.   Recordset.PacketRecords := -1;
  178.   Recordset.SQL.Text := Query;
  179.   Recordset.Open;
  180. End;
  181.  
  182. Procedure defExecute(var Recordset: TSQLQuery; Query: String);
  183. Begin
  184.   Recordset.Free;
  185.   Recordset := TSQLQuery.Create(nil);
  186.   Recordset.UsePrimaryKeyAsKey := False;
  187.   Case DB_MODE Of
  188.      //1: //Recordset.DataBase := mdbWGR;
  189.      2: Recordset.DataBase := sqlConnDEF;
  190.   End;
  191.   Recordset.PacketRecords := -1;
  192.   Recordset.SQL.Text := Query;
  193.   Recordset.Open;
  194. End;
  195.  
  196. procedure EditField(ToEditField, Tabelle, ToEdit, DATA : String);
  197. var
  198.    SQLQuery : TSQLQuery;
  199. begin
  200.    SQLQuery := TSQLQuery.Create(Nil);
  201.    SQLQuery.DataBase := sqlConnWGR;
  202.  
  203.    SQLQuery.FieldByName('SELECT * FROM ' +Tabelle+ ' WHERE DATA = ' +DATA+ ';');
  204.    SQLQuery.Edit();
  205.    SQLQuery.FieldByName(ToEditField).NewValue := ToEdit;
  206.    SQLQuery.Post();
  207.    SQLQuery.UpdateMode :=  upWhereAll;
  208.    SQLQuery.ApplyUpdates();
  209.    SQLQuery.Close
  210. end;
  211.  
  212. exports
  213.   EditField,
  214.   initNetworkDB,
  215.   initdb,
  216.   exitNetworkDB,
  217.   dbExecute,
  218.   wgrExecute,
  219.   defExecute;
  220. end.
  221.  
  222.  

it came until
« Last Edit: October 28, 2020, 02:11:00 pm by Weitentaaal »

440bx

  • Hero Member
  • *****
  • Posts: 2047
Re: application could not be started correctly (0xc000007)
« Reply #4 on: October 28, 2020, 02:23:39 pm »
I suggest you do this:

1. Reboot your computer
2. Immediately run the program that is giving you problems

The question is: does the program run successfully or not immediately after a reboot ?

If successful then it is quite likely the problem is caused by something external to the program (such as page file usage), if not then the cause of the problem is likely due to something in the code.

HTH.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Weitentaaal

  • Jr. Member
  • **
  • Posts: 56
Re: application could not be started correctly (0xc000007)
« Reply #5 on: October 28, 2020, 02:29:50 pm »
Still the same it runs the initNetworkDb Method in my external dll and after that i runs until dbExecute, where the Programm just stops without a Message or Error

440bx

  • Hero Member
  • *****
  • Posts: 2047
Re: application could not be started correctly (0xc000007)
« Reply #6 on: October 28, 2020, 04:06:34 pm »
If I interpreted your reply correctly, that means your program loads and executes.  This would indicate there is no longer a page file related problem.

The description you provided of the problem indicates it is caused by something "not quite right" in your code.

My knowledge of the LCL is much too limited to be of further help but, I suggest you run your test program under the debugger and inspect the results at each statement until you find the point/statement where the result/data is no longer as you expect it.

That can hopefully provide enough information to someone more knowledgeable about the LCL to suggest an appropriate course of action.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Weitentaaal

  • Jr. Member
  • **
  • Posts: 56
Re: application could not be started correctly (0xc000007)
« Reply #7 on: October 28, 2020, 04:46:16 pm »
Yea i already Tryed it but as u can see in my Unit1 (Test Code) there is the Method dbExecute called. If i go over it with the Debugger it stops at this Line and i can't go any further.
At this Point there is nothing that happens anymore. It's like u would just Execute the Programm until this point and then stop it and close it without saying anything.

Is there any Mistake i made by using external dll's ? because it must be a problem with the dll i think (second codeblock posted above)

rvk

  • Hero Member
  • *****
  • Posts: 4386
Re: application could not be started correctly (0xc000007)
« Reply #8 on: October 28, 2020, 05:19:59 pm »
Yikes... Freeing TSQLQuery inside a dll?
Passing a string in a dll-call?

Are you sure they (main program and dll) are using the same shared memorymanager?
(I don't see anything like that in the source)
Without it, passing TSQLQuery and strings can be problematic (I thought).

Weitentaaal

  • Jr. Member
  • **
  • Posts: 56
Re: application could not be started correctly (0xc000007)
« Reply #9 on: October 29, 2020, 07:39:13 am »
How can i see the shared memory manager ?
i think i just will rewrite this mess, thank u guys for ur help :)

PascalDragon

  • Hero Member
  • *****
  • Posts: 2405
  • Compiler Developer
Re: application could not be started correctly (0xc000007)
« Reply #10 on: October 29, 2020, 09:12:46 am »
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   sqldb,  SQLite3Conn, DB;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27.   Procedure dbExecute(var Recordset: TSQLQuery; Query: String); external 'networkdb.dll';
  28.   Procedure initNetworkDB(MacAdresse, pathToWGR: String; ZeichnungsNr: Integer; DATABASE_MODE: Integer = 2);external 'networkdb.dll';
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure TForm1.Button1Click(Sender: TObject);
  37. var
  38.   dbT: TSQLQuery;
  39. begin
  40.   ShowMessage('Before dll');
  41.   initNetworkDB('rand','C:\WGKBlck\Data\', 1, 2);
  42.   ShowMessage('t1');
  43.   dbT := TSQLQuery.Create(nil);
  44.   showMessage('t2');
  45.   showMessage('t3');
  46.   dbExecute(dbT ,'SELECT * FROM Plattentauscher');
  47.   ShowMessage('t4');
  48.  
  49.   ShowMessage(dbT.FieldByName('INDEX').Text);
  50.  
  51.   dbT.Free;
  52. end;
  53. end.
  54.  

Do not pass class instances as such across binary boundaries. This is an accident waiting to happen.

You need to handle this with opaque types (and rvk is right about strings as well, though those could be solved with a shared memory manager). For example:

Code: Pascal  [Select][+][-]
  1. type
  2.   TDllQuery = Pointer;
  3.   TDllField = Pointer;
  4.  
  5.   Procedure dbExecute(Recordset: TDllQuery; Query: String); external 'networkdb.dll';
  6.   Procedure initNetworkDB(MacAdresse, pathToWGR: PChar; ZeichnungsNr: Integer; DATABASE_MODE: Integer = 2);external 'networkdb.dll';
  7.   function CreateQuery: TDllQuery; external 'networkdb.dll';
  8.   procedure FreeQuery(aQuery: TDllQuery); external 'networkdb.dll';
  9.   function QueryFieldByName(aQuery: TDllQuery; aField: PChar): TDllField; external 'networkdb.dll';
  10.   function FieldText(aField: TDllField): PChar; exteranl 'networkdb.dll';
  11.  

In your library  you can simply return the class instance of the TSQLQuery or the TField, but you must not access it as such outside of your library.

Essentially you need to flatten your API if you want to use it like that.

Such problems will only be solved once the compiler and RTL fully support dynamic packages.

Weitentaaal

  • Jr. Member
  • **
  • Posts: 56
Re: application could not be started correctly (0xc000007)
« Reply #11 on: November 02, 2020, 12:56:47 pm »
Thank u :) I know what my mistakes are now :)

 

TinyPortal © 2005-2018