Hello,
I am developing classes in C# that are called from PHP via COM. The C# code
does a lot of work to establish internal data structures, and I would like
these data structures to persist so that I do not have to recreate them each
time the COM code is called.
For example, imagine a function MyObject.BuildInternalDataStructures() which
takes a long time. Another function, MyObject.UseInternalDataStructures(),
is called repeatedly. The first time UseInternalDataStructures is called,
it detects that the structures haven't been built, so it calls
BuildInternalDataStructures. Subsequent calls to UseInternalDataStructures
do not need to incur the penaly of building the internal data structures.
The problem is that on my web server, PHP instantiates a new instance of my
object each time a PHP page is hit -- and destroys the object (and unloads
my DLL) when the page completes executing. So the next time the user hits a
PHP page that calls out to MyObject.UseInternalDataStructures(), it has to
rebuild everything again from scratch.
Is there a way to build a COM server as an EXE, so that it can run in the
background, maintaining its state, while allowing COM consumers (such as
PHP) to call into it?
Thanks
Greg 3 3441
Hi, The problem is that on my web server, PHP instantiates a new instance of my object each time a PHP page is hit -- and destroys the object (and unloads my DLL) when the page completes executing. So the next time the user hits a PHP page that calls out to MyObject.UseInternalDataStructures(), it has to rebuild everything again from scratch.
Does it unload the dll? That seems like very inefficienty ! , imagine 100
requests each loading/unloading the same dll
Is there a way to build a COM server as an EXE, so that it can run in the background, maintaining its state, while allowing COM consumers (such as PHP) to call into it?
First of all I would check in the unloading matter, it should be
configurable somehow.
If not possible then what you could do is using another process to hold the
internal structures, then the dll can communicate with it using remoting for
example. In anyway it would be less efficient.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:OH*************@TK2MSFTNGP15.phx.gbl... Hi,
The problem is that on my web server, PHP instantiates a new instance of my object each time a PHP page is hit -- and destroys the object (and unloads my DLL) when the page completes executing. So the next time the user hits a PHP page that calls out to MyObject.UseInternalDataStructures(), it has to rebuild everything again from scratch.
Does it unload the dll? That seems like very inefficienty ! , imagine 100 requests each loading/unloading the same dll
I agree. It is much more likely that your objects are destroyed, but your
DLL is not unloaded. This is how ASP.OLD worked. If this is the case you
have static scope to store data between calls. Just be sure to make access
to static resources thread-safe.
David
Gregory,
I think it is a simple matter of moving your data structures to a static
variable. Once the CLR is loaded, it is not going to be unloaded for the
life of the process (or at least, it shouldn't). Just make it static.
And if you find that the CLR is being unloaded, then I would create a
class derived from ServicedComponent which uses object pooling. You can
then create a pool of your objects, and incur the cost of initializing your
data structures on construction of your object.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Gregory Hassett" <gh******@hotmail.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl... Hello,
I am developing classes in C# that are called from PHP via COM. The C# code does a lot of work to establish internal data structures, and I would like these data structures to persist so that I do not have to recreate them each time the COM code is called.
For example, imagine a function MyObject.BuildInternalDataStructures() which takes a long time. Another function, MyObject.UseInternalDataStructures(), is called repeatedly. The first time UseInternalDataStructures is called, it detects that the structures haven't been built, so it calls BuildInternalDataStructures. Subsequent calls to UseInternalDataStructures do not need to incur the penaly of building the internal data structures.
The problem is that on my web server, PHP instantiates a new instance of my object each time a PHP page is hit -- and destroys the object (and unloads my DLL) when the page completes executing. So the next time the user hits a PHP page that calls out to MyObject.UseInternalDataStructures(), it has to rebuild everything again from scratch.
Is there a way to build a COM server as an EXE, so that it can run in the background, maintaining its state, while allowing COM consumers (such as PHP) to call into it?
Thanks
Greg
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Patrick |
last post by:
I am almost certain that I could use HTTP Post/Get to submit XML Web Service
call (over SSL as well, if using Version 3 of MSXML2) from an ASP
Application?
However, would I only be able to call...
|
by: Shashank Date |
last post by:
/*
C# Gurus,
I am trying to use interop marshalling to call SetCommTimeouts win32 API.
But I keep getting the "Object reference not set to an instance of an
object" error.
Can anybody help...
|
by: Craig |
last post by:
I am having problems getting an ActiveX DLL written in VB6 to call a
method in a C# class library component.
My C# DLL is called CSharpProject.dll and contains a public class
called CSharpClass....
|
by: Josef |
last post by:
Hello,
I want to create a C# class library which I can use in an Excel VBA macro. I
created a C# class library and set the "Register for COM Interop" option in
Visual Studio to TRUE. Now in...
|
by: Razzie |
last post by:
Hey all,
I'm really going through a small hell right now - I've completely lost it :)
I made a project, using two interop libraries from exchange (created them as
in this msdn article:...
|
by: Hatim Ali |
last post by:
Hello,
I have a class library project which has a class supporting COM+
transactions. This class library project refers a COM interop assembly. Now i
need to register the assembly after...
|
by: Rob Edwards |
last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message:
"A reference to 'Microsoft CDO for Exchange Management Library' could not be...
|
by: JimM |
last post by:
what do I need to use in vb.net to create an object as I do in vb6:
Dim o as Object
Set o = CreateObject("Class1.Test")
Thanks
|
by: Greg |
last post by:
I have a very simple Visual Basic .NET 2003 class library project
ClassLibrary1 configured to run an external program (in this case
C:\WINDOWS\system32\wscript.exe), in the Debugging Configuration...
|
by: ropo |
last post by:
I am using .NET 2.0
I have a C#.Net App, which uses a .NET Class Library, which accesses a
COM object through interop.
The C#.Net App also uses a mixed mode C++.Net Class library which uses
an...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |