Author |
|
coupling
Joined: 26 Jan 2012 Posts: 7
|
Posted: Thu 26 Jan '12 16:39 Post subject: apache vs. php.exe |
|
|
I am currently running Apache 2.3.16 with PHP 5.3.9, both from this site. Right now Apache is configured with:
Code: | Load Module php5_module "C:\...\php5apache2_4.dll |
I am trying to use a third-party .NET dll in php. I can successfully load the dll as a php object using DOTNET. However, when I call a method, I always get the exception:
Quote: | Source: System.Windows.Forms Description: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application. |
However, if I use a command prompt to run php.exe, then my program works perfectly. From what I read, it’s better to run php as an Apache module rather than as a CGI binary, and as of yet I haven’t gotten anything to work when I try to configure it as a CGI binary. I don't know if that is the issue or not. Does anyone have any idea what might be causing this issue? Thanks. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7377 Location: Germany, Next to Hamburg
|
Posted: Fri 27 Jan '12 11:27 Post subject: |
|
|
This is just a bit guessing
Quote: |
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation.
|
Do you run apache as service or in a console?
Quote: |
Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
|
Can you set those settings? Any manual from the 3rd party dll? |
|
Back to top |
|
coupling
Joined: 26 Jan 2012 Posts: 7
|
Posted: Fri 27 Jan '12 16:02 Post subject: |
|
|
I am running Apache as a service on a Windows Server 2008 SP1 operating system.
I have tried changing the settings in the Apache service to "Allow service to interact with desktop", but that did not change the error. I'm not sure what other settings to change.
I have been in contact with the 3rd party dll developer, and he does not know what is going on. I would tend to pin it on something in their code, except that it worked fine when running through php.exe from the console. So it seems that the php code itself is fine, but there is something in the way that Apache reads it that isn't working. I don't know enough about the differences between running Apache with the php module vs. FastCGI to know whether that is a route worth pursuing or not.
Thanks for your help! |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Fri 27 Jan '12 21:16 Post subject: |
|
|
Well, understanding "modal" may help, and since we're talking Windows Forms.
If you pop a secondary window/dialog up from an desktop app and specify "model", the 2nd window/dialog sits on top and in focus, if you try to click on the window underneath it, Windows will make noise and you will not be able to get to it, the one on top will stay on top till it is closed, at which point you can resume working on the one you started on again.
This allows this secondary window/dialog not to get lost underneath. I have an app where the secondary dialog can get lost underneath, yet will not return control to main window till closed. It's very difficult to get back from.
How this all works in respect to this being run under php through an Apache is hazy, since I have no way to understand what exactly is going on. Why it works from the desktop is that the desktop is using UserInteractive mode.
One could try running Apache itself from a console and giving it a try. It also may help doing a little googling on the ServiceNotification keyword.
Services run hidden, therefor any dialog they may pop up are also hidden and cannot be modal, which is why most things being run as a service (say antivirus for example) have a secondary app that communicates with them (taskbar icon for example). |
|
Back to top |
|
coupling
Joined: 26 Jan 2012 Posts: 7
|
Posted: Fri 27 Jan '12 21:45 Post subject: |
|
|
I tried running Apache from a console, and the program works without any problems.
So, what does this mean? Does that indicate a bug in Apache in that it provides a different response when run differently? Is there any problem or disadvantage to running Apache from a console vs. running it as a service?
Thanks. |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Fri 27 Jan '12 22:00 Post subject: |
|
|
There's a disadvantage to running apache from the console, the biggest being the console must stay open and, it will run with the rights of the logged in user, which if Administrator is not good at all. No it's not a bug in Apache, it's just how services operate on Windows.
I've been doing a little googling.
Is this supposed to work on the server machine only? Or is someone out in world supposed to see it?
If it is just for the server side, one can run a service under a user other than SYSTEM (default that services run as). I found a decent explanation of what is happening.
Quote: | Remember that this code is running on the web server in a process that is not running as the currently logged on (to the server) user. Therefore the process will be running under its own Window Station, and will not be able to interact with the desktop in any way. |
I would not run Apache as a service under a power user, but limited user, and just log into the desktop of the server as that user, when this script goes to pop up the dialog, it may be able to do it then.
EDIT: This also has the advantage of allowing you to lock the Apache out of parts of the file system as well.
There are also some workarounds in the thread I read, they may or may not be usable however in your circumstance.
http://forums.asp.net/t/907491.aspx/1 |
|
Back to top |
|
coupling
Joined: 26 Jan 2012 Posts: 7
|
Posted: Fri 27 Jan '12 22:16 Post subject: |
|
|
Yes, I discovered that disadvantage to running from the console soon after my last post, when I logged off the server and then nothing worked.
I will try running the Apache service under a different user.
However, maybe I have missed an important point in my explanation. I do not expect to have any user interaction with the program I am trying to run. When everything runs as expected, I get a simple string as the response. The only place where a modal dialog could appear is when there is an error in the 3rd-party dll I am using. So it would seem that an error is occurring in that dll somewhere, but it doesn't make sense to me why it would work without errors when Apache is run from the console but would have errors when Apache is run as a service. The dll is the same either way. |
|
Back to top |
|
coupling
Joined: 26 Jan 2012 Posts: 7
|
Posted: Fri 27 Jan '12 22:19 Post subject: |
|
|
Oh, yeah, and to answer your question. As of now, this is intended to be used within our companies' local intranet. Someone "out in the world" hopefully will not have access to it, but multiple clients will access it through our network. |
|
Back to top |
|
coupling
Joined: 26 Jan 2012 Posts: 7
|
Posted: Fri 27 Jan '12 22:35 Post subject: |
|
|
I tried running the Apache service as a different user (not SYSTEM), and the program worked as it should. That seems quite bizarre to me, but I'm glad that it works. Thanks for your help! |
|
Back to top |
|
coupling
Joined: 26 Jan 2012 Posts: 7
|
Posted: Fri 27 Jan '12 23:05 Post subject: |
|
|
The dll is from http://www.multiwareinc.com/pawcom2.html. You can download the trial, but unless you have Peachtree accounting software, I don't think you'll be able to do anything with it. Thanks again for your help. |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Fri 27 Jan '12 23:08 Post subject: |
|
|
heh heh, you caught my post before I deleted it. after re-reading your first again, I realized that it was probably not what I had thought it was.
Thanks though |
|
Back to top |
|