Dejan Dozet
Dejan Dozet

Reputation: 1009

App produces an exception on target computers

I've a simple app that uses this:

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  Winapi.Windows, System.Variants, FMX.DialogService, TLHelp32,
  PlayForm, FMX.Platform, FMX.Media, FMX.Types, FMX.Controls, FMX.Forms,
  FMX.Graphics, FMX.Dialogs, FMX.Layouts, FMX.StdCtrls, System.IOUtils,
  FMX.Controls.Presentation, FMX.Colors, FMX.Edit, FMX.Objects, FMX.ListBox;

Then it is compiled and copied to another computer it produces this error:

Exception EAccessViolation in module Kvigraonica.exe at 0054B0F7.

Access violation at address 0094B0F7 in module 'Kvigraonica.exe'. Read of address 0000000C.

OnCreate event is like this:

procedure TfrmMain.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  try
    TDialogService.PreferredMode := TDialogService.TPreferredMode.Platform;
    if tfile.Exists(System.SysUtils.GetCurrentDir + '\team-a.jpg') then
    begin
      imgTeamA.LoadFromFile(System.SysUtils.GetCurrentDir + '\team-a.jpg');
      imgTeamA.TagString := System.SysUtils.GetCurrentDir + '\team-a.jpg';
    end;
    if tfile.Exists(System.SysUtils.GetCurrentDir + '\team-a.png') then
    begin
      imgTeamA.LoadFromFile(System.SysUtils.GetCurrentDir + '\team-a.png');
      imgTeamA.TagString := System.SysUtils.GetCurrentDir + '\team-a.png';
    end;
    if tfile.Exists(System.SysUtils.GetCurrentDir + '\team-a.gif') then
    begin
      imgTeamA.LoadFromFile(System.SysUtils.GetCurrentDir + '\team-a.gif');
      imgTeamA.TagString := System.SysUtils.GetCurrentDir + '\team-a.gif';
    end;
    if tfile.Exists(System.SysUtils.GetCurrentDir + '\team-b.jpg') then
    begin
      imgTeamB.LoadFromFile(System.SysUtils.GetCurrentDir + '\team-b.jpg');
      imgTeamB.TagString := System.SysUtils.GetCurrentDir + '\team-b.jpg';
    end;
    if tfile.Exists(System.SysUtils.GetCurrentDir + '\team-b.png') then
    begin
      imgTeamB.LoadFromFile(System.SysUtils.GetCurrentDir + '\team-b.png');
      imgTeamB.TagString := System.SysUtils.GetCurrentDir + '\team-b.png';
    end;
    if tfile.Exists(System.SysUtils.GetCurrentDir + '\team-b.gif') then
    begin
      imgTeamB.LoadFromFile(System.SysUtils.GetCurrentDir + '\team-b.gif');
      imgTeamB.TagString := System.SysUtils.GetCurrentDir + '\team-b.gif';
    end;

  except on E: Exception do
    ShowMessage(e.Message);
  end;

end;

And I have a timer:

procedure TfrmMain.tmr1Timer(Sender: TObject);
begin
  try

    if (cbbTeamA.Items.Count = 1) then
    begin
      EnumWindows(@EnumWindowsProc, LPARAM(cbbTeamA));
    end
    else
    if (cbbTeamA.Items.Count = 0) or ((cbbTeamA.Selected <> nil) and (cbbTeamA.Selected.Index = 0)) then
    begin
      cbbTeamA.Clear;
      cbbTeamA.Items.AddObject('Izaberite VLC player Ekipu A', TObject(0));
      cbbTeamA.ItemIndex := 0;
      EnumWindows(@EnumWindowsProc, LPARAM(cbbTeamA));
    end;

    if (cbbTeamB.Items.Count = 1) then
    begin
      EnumWindows(@EnumWindowsProc, LPARAM(cbbTeamB));
    end
    else
    if (cbbTeamB.Items.Count = 0) or ((cbbTeamB.Selected <> nil) and (cbbTeamB.Selected.Index = 0))  then
    begin
      cbbTeamB.Clear;
      cbbTeamB.Items.AddObject('Izaberite VLC player za Ekipu B', TObject(0));
      cbbTeamB.ItemIndex := 0;
      EnumWindows(@EnumWindowsProc, LPARAM(cbbTeamB));
    end;
  except on E: Exception do
    ShowMessage(e.Message);
  end;
end;

I have more events and procedures, but here I put the ones that I think are the most important. Now, even if I comment out all events and procedures I still have the same error:

Exception EAccessViolation in module Kvigraonica.exe at 0054B0F7.

Access violation at address 0094B0F7 in module 'Kvigraonica.exe'. Read of address 0000000C.

Is there anything that FMX relies on so I have to install it on the target systems?

UPDATE

I've found that the problem is in a stylebook that I am using.

I've followed @StijnSanders advice (with @TomBrunberg help too) and I got this:

enter image description here

And this is when I lookup caller:

enter image description here

Upvotes: 1

Views: 195

Answers (1)

Stijn Sanders
Stijn Sanders

Reputation: 36840

Press F7 which starts your project with the debugger, this will enable an option 'Go to Address' under the Search menu. Use it to look up address $0094B0F7. Optionally read more about debugging in the manual to find out how you can run the program up to the point where it fails.

Upvotes: 2

Related Questions