FastReport in service DLL

edited 12:48AM in FastReport 4.0
I have used uniGUI to create a delphi web app. Very cool system. Works great. I wanted to add FastReports to it. So, I added a bunch of reports. I noticed that one of them kept locking up the DLL. My app is compiled as a DLL that the MS ASAPI loads. That way it's integrated with Web services IIS for microsoft.

Anyway, the TfrxRichVew object that I have on the report seems to be causing me a problem. If the source of the creation of the object, you will see this....
constructor TfrxRichView.Create(AOwner: TComponent);
procedure writeln(mess:String);
Var
file1:textfile;
file2:text;
begin
{$I-}
If fileexists('C:\inetpub\wwwroot\Davie\Writeln.txt')=false Then
Begin
assignfile(file1,'C:\inetpub\wwwroot\Davie\Writeln.txt');
rewrite(file1);
closefile(File1);
end;
assignfile(file1,'C:\inetpub\wwwroot\Davie\Writeln.txt');
reset(file1);
append(file1);
system.writeln(file1,mess);
closefile(File1);
if ioresult<>0 then ;
end;
begin
writeln('frxRichView Debug START');
inherited;
writeln('frxRichView Debug 2');
FRichEdit := TrxRichEdit.Create(nil);
writeln('frxRichView Debug 3');
FRichEdit.Parent := frxParentForm;
writeln('frxRichView Debug 3 frxParentForm.Handle='+IntToStr(frxParentForm.Handle));
writeln('frxRichView Debug 3 FRichEdit.Handle='+IntToStr(FRichEdit.Handle));
writeln('frxRichView Debug 4');
SendMessage(frxParentForm.Handle, WM_CREATEHANDLE, frxInteger(FRichEdit), 0);
writeln('frxRichView Debug 5');
FRichEdit.AutoURLDetect := False;

{ make rich transparent }
SetWindowLong(FRichEdit.Handle, GWL_EXSTYLE,
GetWindowLong(FRichEdit.Handle, GWL_EXSTYLE) or WS_EX_TRANSPARENT);

writeln('frxRichView Debug 6');
FTempStream := TMemoryStream.Create;
FTempStream1 := TMemoryStream.Create;

FAllowExpressions := True;
FExpressionDelimiters := '[,]';
FGapX := 2;
FGapY := 1;
FWysiwyg := True;
FHasNextDataPart := False;
writeln('frxRichView Debug DONE');
end;

I put some debug code in the procedure so I could see where it was locking up. It was on the SENDMESSAGE. You will notice that the usage of frxParentForm is also used. This variable is GLOBAL. I don't see how this can be thread safe. Am I missing something here or is the TfrxRichView object NOT threadsafe?

Also, I noticed that while on a single thread(one web user), that if I create and destroy the report component many times, it eventually locks ont he SENDMESSAGE. It's as though the handle for the sendmessage is not responding and thus will freeze.

Also, on my debug line where it referes to FRichEdit.Handle, it will lock up. So, I think there's some wierd stuff going on with the RichView.

So, in summary, there are two concerns. 1) Is it thread safe<no globals being used> and 2) Can I use it in a DLL where I don't think there is a message pump.

Can anyone enlighten me on this?

thanks

Davie

Comments

  • edited 12:48AM
    I have run into the same issue.

    I am generating reports on a schedule in a windows service. It hangs when there is a richtext object, exactly as described by Davie.

    The SendMessage goes to a handle that has no message processing and as a result the thread is hung.

    How can I deal with this?

    Thanks,
    Tony
  • edited 12:48AM
    In continuing my research I found this document https://www.danysoft.com/free/Informes%20en...con%20hilos.pdf

    At one point it states: "Try building reports without using RichText objects because by so doing you can get an unstable application."

    But it doesn't give any information to support this.

    Any help would be great!
  • I have the same problem with richtextObject is not thread safe on sendmessage....

    I use Fast-Report 6.5

    on line 153 in frxRich.pas : SendMessage(frxParentForm.Handle, WM_CREATEHANDLE, frxInteger(FRichEdit), 0); hangs on run in a thread :-(

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.