Jump to content
RDP1974

tform inside isapi webbroker

Recommended Posts

hi,

I like to test if can be possible to embed a not visible tform within a isapi

I get an exception "only one datamodule for application"

perhaps somebody knows if can be done?

Share this post


Link to post
2 hours ago, RDP1974 said:

perhaps somebody knows if can be done?

Yes i know, and no it is impossible to create any GUI element from IIS ISAPI.

 

The reason is simple your ISAPI is either running in-process or out-of-process of the INET/IIS, in both cases the ISAPI is hosted by Windows Service, all Windows Services are not allowed to create (or interact with) any GUI or have user desktop interaction.

Share this post


Link to post
13 hours ago, RDP1974 said:

exception "only one datamodule for application"

@Kas Ob., I got this same error just yesterday--not for creating a TForm but for creating a TDataModule. I thought for sure I could create a data module in addition to the web module used by the ISAPI DLL. Certainly, this is a different issue, right?

 

@RDP1974, Why would you want a Form in a web module? If you want to display something, it would be returning HTML through a web action. Or, you could create a CGI app and run it from the console to see some output--but that's still not going to allow a TForm.

Share this post


Link to post
11 hours ago, corneliusdavid said:

@Kas Ob., I got this same error just yesterday--not for creating a TForm but for creating a TDataModule. I thought for sure I could create a data module in addition to the web module used by the ISAPI DLL. Certainly, this is a different issue, right?

DataModule should be created fine, the problem is what is on it !!?

1) The OP asked for non visible TForm, invisibility of TForm is irrelevant here, because handles for Windows classes is the prohibited in Windows Services, These Windows services are isolated from the user or interacting with the user.

2) Windows services are console application, this is very important, on top of that they are console application with modified policy to block all the GUI API https://learn.microsoft.com/en-us/windows/win32/services/interactive-services not only they can't create but also they cant open handles.

3) I created hundreds of DataModules in my services, in fact it is the cleanest or most efficient way to build Windows service, but you can't drop one VCL component on it, by that i mean a visible one or the one that create Windows GUI class, i faced some problems with a component should be as non visible component, but this component had hidden form/dialog to ask for a password if needed or programmatically asked to do so, that component was creating that input dialog in the constructor, this component had to be modified to be used in a DataModule in Windows Service.

 

Now to guessing part to what did happen with your DataModule in ISAPI, most likely you have unit in uses clause that do some GUI initialization and does fail or something, see, i don't have the latest Delphi, but reading what have being changed and added, it might be the theming and skinning have something to do with, so in theory (i might be wrong here), you might used some component that is importing some of these units, or you have tested your module in an stand alone EXE and forgot to remove some unit from the uses clause, so i recommend to check the uses part, and track the offending component on that DataModule.

 

Share this post


Link to post
8 hours ago, Kas Ob. said:

the problem is what is on it !!?

There was nothing but FireDAC database components, a FDConnection and a few FDQueries--that's it. But--I found the problem!

 

I had first created a FireMonkey program to test database connection and query results. Then I created an ISAPI DLL and copied the data module over and got the error. For easier debugging, I created a new a CGI app with just "hello world" for the default path, and that worked. So, then looked more closely at the data module and remembered to check the platform to which it's assigned and realized it had carried over the Firemonkey platform in its data module.

 

The solution was to change the ClassGroup property of the data module from FMX.Controls.TControl to System.Classes.TPersistent and all is good.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×