Jump to content

Error:The process cannot access the file because it is being used by another process


bahry

Recommended Posts

Hi,

Am receiving this strange error while generating a PDF file while try to load the generated PDF with (UniPDFFrame or UniURLFrame) "The process cannot access the file because it is being used by another process" in the development machine every thing works smooth without any problem, but it appears in the deployed machine and I have change to other deployed machine with the same error.

am using the latest version of FastReport with the latest version of UniGui.

 

Regards

 

Link to comment
Share on other sites

Hi,

Here is the log file it seems a permission error, in spite of the program runs under Administrator with full permission on the folder 

any Idea?

 

////////////////////////////////////////

UniGui_Test.exe: 000393E0: 10:12:48 [TUniServerModule]:Server First Init.
UniGui_Test.exe: 000393E0: 10:12:48 [TUniServerModule]:Erasing Cache Folder...
UniGui_Test.exe: 000393E0: 10:12:48 [TUniServerModule]:Cache Folder Erased. <0> Files deleted.
UniGui_Test.exe: 000393E0: 10:12:48 [TUniServerModule]:Starting HTTP Server...
UniGui_Test.exe: 000393E0: 10:12:48 [TUniServerModule]:HTTP Server Started. Port: 8077
UniGui_Test.exe: 0000FCB8: 10:13:54 [HandleFileRequest[127.0.0.1]]:Access denied: locale.properties.
UniGui_Test.exe: 0000FCB8: 10:13:54 [127.0.0.1]:EFOpenError : Cannot open file "C:\Projects\cache\UniGui_Test_exe\hTu1uNTg9YFF733DFC\$z$z$z\BILGQI170502101354050.pdf". The process cannot access the file because it is being used by another process : Addr: $004BE51B
UniGui_Test.exe: 000393E0: 10:14:26 [TUniServerModule]:Shutting Down Server.
UniGui_Test.exe: 0003964C: 10:14:27 [indy]:EIdNotConnected : Not Connected : Addr: $00702B62
UniGui_Test.exe: 0000FCB8: 10:14:27 [indy]:EIdNotConnected : Not Connected : Addr: $00702B62
UniGui_Test.exe: 0001FDCC: 10:14:27 [indy]:EIdNotConnected : Not Connected : Addr: $00702B62
UniGui_Test.exe: 000150A4: 10:14:27 [indy]:EIdNotConnected : Not Connected : Addr: $00702B62
UniGui_Test.exe: 000393E0: 10:14:27 [TUniServerModule]:HTTP Server Stopped.
UniGui_Test.exe: 000393E0: 10:14:27 [TUniGUISessionManager]:Terminating Session manager.
UniGui_Test.exe: 000393E0: 10:14:27 [TUniGUISessionManager]:Stopping Cache Eraser...
UniGui_Test.exe: 000393E0: 10:14:27 [TUniGUISessionManager]:Cache Eraser Stopped.
UniGui_Test.exe: 000393E0: 10:14:27 [TUniGUISessionManager]:Destroying Worker Threads.
UniGui_Test.exe: 000393E0: 10:14:27 [TUniGUISessionManager]:Session manager terminated.
UniGui_Test.exe: 000393E0: 10:14:27 []:Error deleting file: "C:\Projects\cache\UniGui_Test_exe\hTu1uNTg9YFF733DFC\$z$z$z\BILGQI170502101354050.pdf" [OS Error:32]
UniGui_Test.exe: 000393E0: 10:14:27 []:Error deleting folder: "C:\Projects\cache\UniGui_Test_exe\hTu1uNTg9YFF733DFC\$z$z$z\" [OS Error:145]
UniGui_Test.exe: 000393E0: 10:14:27 []:Error deleting folder: "C:\Projects\cache\UniGui_Test_exe\hTu1uNTg9YFF733DFC\" [OS Error:145]
UniGui_Test.exe: 000393E0: 10:14:27 [TUniServerModule]:Server Shutdown Completed.
UniGui_Test.exe: 000393E0: 10:14:27 []:<-------------------------------------------------------------->
UniGui_Test.exe: 000393E0: 10:14:27 [Terminated]:Exit Code: 0
////////////////////////////////////////
Link to comment
Share on other sites

Hi Farshad,

There is no Anti-Virus , and here is the code

/////////////////////////////////////////////////////////////////////////////

in the report form
 
procedure TStmntFrm.UniSFBitBtn1Click(Sender: TObject);

begin                        
 UniSFHold1.MaskShow('Please wait... Preparing Report',
 procedure(const Mask:Boolean)
 begin
 if Mask then
   begin
     sleep(1000);//your procedure
     PrepareTheReport;
     UniSFHold1.MaskHide;
   end;
 end
 );
end;
procedure TStmntFrm.PrepareTheReport;
var
 dm : TfrDM;
begin
 dm := TfrDM.Create(nil);
 try
   UniPDFFrame1.pdfURL := dm.GenReportPDF(2);
//   UniURLFrame1.URL    := dm.GenReportPDF(2);
 finally
   dm.Free;
 end;
end;


And in the ReptDM Unit


function TfrDM.GenReportPDF(const InvNum: Integer): string;
var
 sPath  : string;
begin
  case InvNum of
   1:begin
     end;
   2:begin                       
      frxReport1.ParentReport := UniServerModule.FilesFolderPath+'templates\MainLand.fr3';
      sPath := UniServerModule.FilesFolderPath+'templates\Stmnt.fr3';
     end;
   3:begin                       
     end;
   4:begin
     end;   
  end;


  try
    frxReport1.PrintOptions.ShowDialog := False;
    frxReport1.ShowProgress := false;


    frxReport1.EngineOptions.SilentMode := True;
    frxReport1.EngineOptions.EnableThreadSafe := True;
    frxReport1.EngineOptions.DestroyForms := False;
    frxReport1.EngineOptions.UseGlobalDataSetList := False;


    frxReport1.LoadFromFile(sPath);
    frxPDFExport1.Background := True;
    frxPDFExport1.ShowProgress := False;
    frxPDFExport1.ShowDialog := False;
    frxPDFExport1.FileName := UniServerModule.NewCacheFileUrl(False, 'pdf', '', '', Result, True);
    frxPDFExport1.DefaultPath := '';
    (*
    frxHTML5DivExport1.ShowProgress := False;
    frxHTML5DivExport1.ShowDialog := False;
    frxHTML5DivExport1.FileName := UniServerModule.NewCacheFileUrl(False, 'html', '', '', Result, True);
    frxHTML5DivExport1.DefaultPath := '';
    *)


    frxReport1.PreviewOptions.AllowEdit := False;
    frxReport1.PrepareReport;
    frxReport1.Export(frxPDFExport1);
 //   frxReport1.Export(frxHTML5DivExport1);
  finally
    CloseDS(InvNum);
  end;
end;
///////////////////////////////////////////////////////////////////////////// 

By the way this is my first time trying to deploy the Application as a Standalone .

on the deployed machine I install FMSoft_uniGUI_Complete_runtime_1.0.0.1391.exe as an administrator 

then copied uniSFJS under the uni-1.0.0.1391

 

Regards

 

Do you have some sort of anti-virus installed on your target PC?

 

How do you generate the PDF file?

Link to comment
Share on other sites

I created new fr3 report not inherited , and applied the S string and still the same error.

 

Regards

 

 

 

procedure TStmntFrm.PrepareTheReport;
var
 dm : TfrDM;
S : string;
begin
 dm := TfrDM.Create(nil);
 try
   S := dm.GenReportPDF(2);
 finally
   dm.Free;
 end;
 UniPDFFrame1.pdfURL := S;
end;

Can you try as above?

 

Link to comment
Share on other sites

I created another report and it is shown, I will rewrite the report from scratch again, in spite of in the development machine it's working without any problem.

and I will try to convert the project to run as a service or ISAPI.

 

Do you get this error in each attempt to generate report?

Link to comment
Share on other sites

Hi Farshad,

Development Machine:
Win 10 Enterprise , Delphi 10.2
Deployment Machines (as a Standalone)
MS VPS win 2012 R2 Dataceneter - Hosted in MS Cloud
VPS Win 2012 R2 Dataceneter - Hosted in WebKeepers
 
I Rewrite the report from scratch with the same error.
Made new project as a Service it hangs from the beginning as if it is not reading the variables from the ini file which is placed in the exe directory.
in the log file I have the following msg. ( [unhandled Web]:EThread : CheckSynchronize called from thread $2CE8, which is NOT the main thread : Addr: $004D057F) 
Run the Project as ISAPI the same as a Service hangs from the beginning.
 
Regards
 

 

Can you specify OS and installex software on your pc?

Sent from my SM-N900 using Tapatalk

Link to comment
Share on other sites

Hi Farshad,

Am using only ODAC, tsiLang, FastReport and all are the latest versions,

anyway am rewriting the application form by form and making the test, the application is only 4 forms and 3 of them are master/detail reports.

 

Regards

 

This error is strange. It seems that your application is trying to use VCL components.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

At long last my problems solved and here is my solution if it face any of you,

 

- First Problem in generating and showing the PDF

In FastReport it seems there is an AV when embedding the Font in the PDF and the font is not present in the deployed machine, so the solution for it 

in unit frxTrueTypeCollection in (function TrueTypeCollection.LoadFont( font: Tfont) : TrueTypeFont;) at line 224, we have to add the following line at the end of the function if Result = nil then Result := ttf.

The Result will be that some fonts will be replaced with others but at least we will have the PDF file.

 

 

- System Hangs if run as a Service or ISAPI

The Problem seems to be from ODAC, when I changed it to UniDAC it works without problem, in spite of both components share the same code base for connection to ORACLE DB, and both works very well as a Standalone but the connection failed when run the Application as a Service or ISAPI.

I will report this error in Devart.

 

 

Regards

Link to comment
Share on other sites

- System Hangs if run as a Service or ISAPI

The Problem seems to be from ODAC, when I changed it to UniDAC it works without problem, in spite of both components share the same code base for connection to ORACLE DB, and both works very well as a Standalone but the connection failed when run the Application as a Service or ISAPI.

I will report this error in Devart.

 

 

That seems to be a problem in latest ODAC Version. Older versions work.

Link to comment
Share on other sites

That seems to be a problem in latest ODAC Version. Older versions work.

 

ODAC ver 10.0.1 has a problem with ORACLE ver 12.1.0.2 in Direct mode, but am using XE, where ODAC works with this version since long time.

But after a huge debug and pulling hear the problem in the new property called schema which suppose to be empty if you shift connections from user to user

Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...