Permission denied creating Singleton in GLOBAL.ASA
Permission denied creating Singleton in GLOBAL.ASA
am 19.10.2007 14:48:19 von Tony Proctor
I need to create a process Singleton object for an ASP application, but I'm
having some odd issues
In my GLOBAL.ASA, I have an
Re: Permission denied creating Singleton in GLOBAL.ASA
am 19.10.2007 17:13:20 von Schmidt
"Tony Proctor" schrieb im
Newsbeitrag news:O8%23$U5kEIHA.4028@TK2MSFTNGP02.phx.gbl...
Hi Toni,
have you seen (and tested) my Shared-Memory-Example
wich I've posted yesterday?
Works very well across the IIS-STAs with
very good performance (no marshaling involved).
To wrap the approach in a way, that it works
(with a binary chop) somehow like a dictionary
should be no problem - you will end up with
a lean Dictionary-Connector-Class, wich works
against a shared Memory-Store, independent
in wich STA this Class would be instantiated.
Regarding your global.asa-question I have no idea.
From my tests yesterday I've at least found, that
it is somehow important to stop the service using:
net stop iisadmin /y
before any change in the "Dll-Environment".
and to start it after that using:
net start w3svc
Stopping and (re)starting in the server-manager was
somehow not sufficient.
But that one you probably already know.
Olaf
Re: Permission denied creating Singleton in GLOBAL.ASA
am 19.10.2007 17:48:58 von Tony Proctor
I did see your example Olaf but it wasn't really applicable for what I need.
I actually have a VB class that stores multiple Dictionary objects in an
array - one per "resource" being cached. Each Dictionary could have 20k-30k
items in it. Hence, the problem with memory usage, and why I need a hashed
lookup rather than a binary chop. It's that encapsulating VB class that I
really want as a singleton.
I can't directly add a VB object to the Application collection, but I can if
it was created via the
Re: Permission denied creating Singleton in GLOBAL.ASA
am 19.10.2007 18:13:23 von reb01501
You probably don't want to be putting apartment-threaded objects in
Application.
http://www.aspfaq.com/show.asp?id=2053
Tony Proctor wrote:
> I did see your example Olaf but it wasn't really applicable for what
> I need. I actually have a VB class that stores multiple Dictionary
> objects in an array - one per "resource" being cached. Each
> Dictionary could have 20k-30k items in it. Hence, the problem with
> memory usage, and why I need a hashed lookup rather than a binary
> chop. It's that encapsulating VB class that I really want as a
> singleton.
>
> I can't directly add a VB object to the Application collection, but I
> can if it was created via the
Re: Permission denied creating Singleton in GLOBAL.ASA
am 19.10.2007 18:20:32 von Tony Proctor
I've read that Bob but this object has to be a Singleton
Tony Proctor
"Bob Barrows [MVP]" wrote in message
news:OqSQ6rmEIHA.4400@TK2MSFTNGP05.phx.gbl...
> You probably don't want to be putting apartment-threaded objects in
> Application.
> http://www.aspfaq.com/show.asp?id=2053
>
> Tony Proctor wrote:
> > I did see your example Olaf but it wasn't really applicable for what
> > I need. I actually have a VB class that stores multiple Dictionary
> > objects in an array - one per "resource" being cached. Each
> > Dictionary could have 20k-30k items in it. Hence, the problem with
> > memory usage, and why I need a hashed lookup rather than a binary
> > chop. It's that encapsulating VB class that I really want as a
> > singleton.
> >
> > I can't directly add a VB object to the Application collection, but I
> > can if it was created via the
Re: Permission denied creating Singleton in GLOBAL.ASA
am 19.10.2007 19:46:13 von Schmidt
"Tony Proctor" schrieb im
Newsbeitrag news:OM7$QemEIHA.5980@TK2MSFTNGP04.phx.gbl...
> I did see your example Olaf but it wasn't really applicable
> for what I need.
I'd say, that you could adapt the approach very easy
to your problem.
> I actually have a VB class that stores multiple Dictionary
> objects in an array - one per "resource" being cached.
> Each Dictionary could have 20k-30k items in it.
That's also no problem, since you could hold separate
Arrays (as much as you want) for each resource.
I assume, your current Dictionaries store simple
StringKey<->SingleValue-Pairs for each resource
(accessing each Value over the hashed StringKey).
You can do exactly the same with my approach, and
you could even store StringKey<->MutipleRecordValues
without any problems as long as the RecordValues
only contain simple Types (Strings, Longs, Doubles, etc.).
> Hence, the problem with memory usage, and why I need
> a hashed lookup rather than a binary chop.
The binary chop was meant to work on the (sorted)
StringKeys of each "Record-Entry" and if implemented
right, retrieving Values by Key or a check for KeyExists
is processed at the same speedlevel as the hashed lookup
of the MS-ScriptingDictionary or the VB-Collection.
In fact the keyed-access would be *much* faster in your
special case, than working against a *marshaled* singleton-
object, because of the non-existent OLE-Call-overhead.
If you work readonly against your Resource-Caches,
you wouldn't even need to implement CriticalSection-
based locking with this approach.
In the current example there is also an defined entry-
point for the STA, wich is the first user of the shared
cache - at this point you could fill all your data into
each of the Resource-Caches.
But I understand, that you want to avoid coding-effort
and that reusing your already existing Resource-Cache-
Class as a singleton would be the easiest way (if you
manage, to get proper singleton-instancing in global.asa).
Just let me know, when the marshaled singleton-approach
doesn't work as you imagine - would enhance the example
then with "multiple Resource-Caching-capabilities" + some
appropriate KeyExists and GetRecordByKey-Methods
for the multiple Resource-Caches.
Olaf
Re: Permission denied creating Singleton in GLOBAL.ASA
am 19.10.2007 22:10:13 von Anthony Jones
"Tony Proctor" wrote in message
news:O8%23$U5kEIHA.4028@TK2MSFTNGP02.phx.gbl...
> I need to create a process Singleton object for an ASP application, but
I'm
> having some odd issues
>
> In my GLOBAL.ASA, I have an
Re: Permission denied creating Singleton in GLOBAL.ASA
am 20.10.2007 11:26:59 von Tony Proctor
I'm using "High" isolation (this is currently under IIS5 on a W2K box)
I can confirm that a 'New' operator and a CreateObject call both work from
an ASP script. Also, if I instantiate the objects with Session scope via
GLOBAL.ASA then it works. It only seems to fail like this with Application
scope. I've also tried specifying CLASSID= instead of PROGID= in the
GLOBAL.ASA but the results were the same.
The rationale for this is that I need a "singleton" object. I don't care how
I achieve this but it must be callable from any other ASP thread. The
cross-thread calls are a necessary penalty since that singleton will use a
considerable amount of VM for a global cache. I cannot afford to have that
duplicated in every apartment.
Tony Proctor
"Anthony Jones" wrote in message
news:OYgSQwoEIHA.1056@TK2MSFTNGP03.phx.gbl...
> "Tony Proctor" wrote in
message
> news:O8%23$U5kEIHA.4028@TK2MSFTNGP02.phx.gbl...
> > I need to create a process Singleton object for an ASP application, but
> I'm
> > having some odd issues
> >
> > In my GLOBAL.ASA, I have an
Re: Permission denied creating Singleton in GLOBAL.ASA
am 20.10.2007 12:22:06 von Anthony Jones
"Tony Proctor" wrote in message
news:ex34etvEIHA.5328@TK2MSFTNGP05.phx.gbl...
> I'm using "High" isolation (this is currently under IIS5 on a W2K box)
>
> I can confirm that a 'New' operator and a CreateObject call both work from
> an ASP script. Also, if I instantiate the objects with Session scope via
> GLOBAL.ASA then it works. It only seems to fail like this with Application
> scope. I've also tried specifying CLASSID= instead of PROGID= in the
> GLOBAL.ASA but the results were the same.
>
> The rationale for this is that I need a "singleton" object. I don't care
how
> I achieve this but it must be callable from any other ASP thread. The
> cross-thread calls are a necessary penalty since that singleton will use a
> considerable amount of VM for a global cache. I cannot afford to have that
> duplicated in every apartment.
>
In an early post you I think you said that you have other classes built with
VB that you were able to successfully create with an object tag with an
application scope? Can you confirm that is so? Normally any attempt to
assign an object in an STA into the application object would fail.
I think Schmidt was directing you to a more complex but more scalable
solution. What happens when the thread on which the object was created is
currently busy processing an ASP script which potentially may take some
time?
Have you checked the permissions on the DLL and anything the class
initialise may need to access. Ensure that such resources allow
IWAM_ and IUSR_ appropriate access.
--
Anthony Jones - MVP ASP/ASP.NET
Re: Permission denied creating Singleton in GLOBAL.ASA
am 20.10.2007 13:45:19 von Tony Proctor
The DLLs are already part of a working application. It's true that you
cannot directly assign an apartment-threaded object into the Application
variables (you get an error) but you can create such an object with
SCOPE=Application via the