IIS 7 and Above
PHP and COM Interop assembly (written in C#)
Last post Dec 16, 2013 09:58 PM by lextm
Dec 16, 2013 05:41 PM|RhinoNY|LINK
Hi folks, I've got a weird situation here.
I've written a C# COM Intertop assembly which is being accessed from PHP website running under IIS 7.5 over Fast CGI on 2008 R2.
I am seeing unexpected churn within my assembly, with global singleton classes that should only be created once being released and recreated.
At first I thought this was due to worker process recycling, and part of it in fact was due to this due to the IdleTimeout. However, now that this has been fixed, I am still seeing these singletons being released and recreated even though the WP is not
recycling It is almost as if the AppDomain within the WP is being released and recreated.
Since this is a PHP appication, thjere is no way for it to hold a durable reference to any of the COM components across page loads. So what I do is I have created an "access" class and I create an instance of that class every page load, and call a method
which returns the existing Singleton instance (creating it the first time naturally). Please note that the singleton is free-threaded, so there are no performance issues here. I actually want all of the requests be running in separate threads against the
same class instance.
However, I'm seeing no errors in my logs, and as I said the WP isn't crashing (the PID never changes). I've set the IdleTimeout high (1 day), and have also set the ActiveTimeout very high as well. I have no idea why this is happening.
When the same DLL is used from ASP.Net, thsi never happens. Of course, when used from ASP.Net, it is not going through COM Interop.
If anybody has any ideas I'd love to hear it.
Dec 16, 2013 09:58 PM|lextm|LINK
If you carefully read Fast CGI specs, you will see that even when application pool recycle is disabled, Fast CGI mechanism will recycle PHP processes (php-cgi.exe). Thus, your assembly in turn will be freed and reloaded. It is not weird but by design.
A better way to interoperate, is to build a web service in C# where you can make your class fully singleton, and then invoke the service on PHP side.