Installed "Windows Script 5.5" och now I get errormessages. 
Author Message
 Installed "Windows Script 5.5" och now I get errormessages.

I recently installed Windows Sript 5.5, and now I get the following
errormessage in global.asa when I use this code:
----------------------------------------------------------------------------
--------
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
Set Application("Pages") = Server.CreateObject("Scripting.Dictionary")
Set Application("Host") = Server.CreateObject("Scripting.Dictionary")
Set Application("Agent") = Server.CreateObject("Scripting.Dictionary")
Set Application("Starttime") = Server.CreateObject("Scripting.Dictionary")
Set Application("Is_Logged_in") =
Server.CreateObject("Scripting.Dictionary")

Application("Logged_in") = 0
Application("Last_logged_in") = ""
End Sub

</SCRIPT>
----------------------------------------------------------------------------
--------

The errormessage is:

----------------------------------------------------------------------------
--------
Application object error 'ASP 0197 : 80004005'

Disallowed object use

/tfw/global.asa, line 4

Cannot add object with apartment model behavior to the application intrinsic
object.
----------------------------------------------------------------------------
--------

I don't understand why. It worked fine before I installed "Windows Script
5.5"

/Goofy



Sat, 22 Feb 2003 23:31:25 GMT  
 Installed "Windows Script 5.5" och now I get errormessages.
Yes, according to the MSDN information it is not possible anymore to add a
scripting dictionary to an application variable.

It has something to do the apartment threading model and an incorrect
setting in the registry. We checked the registry and everything was set to
the right settings.

Search MSDN for 'apartment threading' and you will find the cause and
solution description. But I'm afraid that it's not solving your problem.


Quote:
> I recently installed Windows Sript 5.5, and now I get the following
> errormessage in global.asa when I use this code:
> --------------------------------------------------------------------------
--
> --------
> <SCRIPT LANGUAGE=VBScript RUNAT=Server>

> Sub Application_OnStart
> Set Application("Pages") = Server.CreateObject("Scripting.Dictionary")
> Set Application("Host") = Server.CreateObject("Scripting.Dictionary")
> Set Application("Agent") = Server.CreateObject("Scripting.Dictionary")
> Set Application("Starttime") = Server.CreateObject("Scripting.Dictionary")
> Set Application("Is_Logged_in") =
> Server.CreateObject("Scripting.Dictionary")

> Application("Logged_in") = 0
> Application("Last_logged_in") = ""
> End Sub

> </SCRIPT>
> --------------------------------------------------------------------------
--
> --------

> The errormessage is:

> --------------------------------------------------------------------------
--
> --------
> Application object error 'ASP 0197 : 80004005'

> Disallowed object use

> /tfw/global.asa, line 4

> Cannot add object with apartment model behavior to the application
intrinsic
> object.
> --------------------------------------------------------------------------
--
> --------

> I don't understand why. It worked fine before I installed "Windows Script
> 5.5"

> /Goofy



Sat, 22 Feb 2003 23:56:57 GMT  
 Installed "Windows Script 5.5" och now I get errormessages.

Well, first, let me say that you shouldn't be using
the Scripting.Dictionary in an ASP project at
the application level.

This would be very bad, espcially if you ever hoped
of having more than 2 or 3 people hit your site at
any one given time.

The Dictionary object was never intended to be used
as an object for ASP.  The Dict object is and apartment
model single-threaded application (STA).

This means that it doesn't scale. It opens up one
process for all callers. This means that if one person
is connected to your site and doing some work with the
dictionary, and someone else connects, they will have to
wait until the first person is done before they can
use the dictionary. To make matters worse, if you have
your web site set to run in-process, it can even tie up
the whole IIS process and cause the whole web site to
become unresponsive while dictionary work is being done!

This would be bad.

Unfortunately, this situation was made worse by the fact
that in the NT OptionPack when it installs the Dictionary,
it marks it as "Both" in the registry which allows IIS
to use it. This was a huge mistake and caused lots of
confusion and headaches.

Visual Studio 6, the new WSH and Windows 2000 all have fixed
the registry mix-up problem resulting in what you have
just experienced.

What can you do then? Well, unfortunately, there's not
much else you can do. Due to the way dictionaries work,
it's difficult to engineer it for multiple simultaneous
access.  If you plan only as using it for read-only access
(except for the initial population of values during the
Application_OnStart) you could write your own multi-threaded
app (MTA) that allows you to have multiple callers. If it's
Read-Only it shouldn't be that bad, but if you have multiple
callers adding/removing/updating records, it gets REAL
complicated and you end up essentially having an in-memory
database that will need transactional control and mulitple-
user-access control, etc. It gets REAL complicated. There are
some COM object R/O dictionaries out there. I can't think of
one off the top of my head, but I do remember seeing them.

Writing one shouldn't be too difficult if you only allow
one population and the rest is all read-only.

-Chad


Quote:
> I recently installed Windows Sript 5.5, and now I get the following
> errormessage in global.asa when I use this code:
> ----------------------------------------------------------------------------
> --------
> <SCRIPT LANGUAGE=VBScript RUNAT=Server>

> Sub Application_OnStart
> Set Application("Pages") = Server.CreateObject("Scripting.Dictionary")
> Set Application("Host") = Server.CreateObject("Scripting.Dictionary")
> Set Application("Agent") = Server.CreateObject("Scripting.Dictionary")
> Set Application("Starttime") = Server.CreateObject("Scripting.Dictionary")
> Set Application("Is_Logged_in") =
> Server.CreateObject("Scripting.Dictionary")

> Application("Logged_in") = 0
> Application("Last_logged_in") = ""
> End Sub

> </SCRIPT>
> ----------------------------------------------------------------------------
> --------

> The errormessage is:

> ----------------------------------------------------------------------------
> --------
> Application object error 'ASP 0197 : 80004005'

> Disallowed object use

> /tfw/global.asa, line 4

> Cannot add object with apartment model behavior to the application intrinsic
> object.
> ----------------------------------------------------------------------------
> --------

> I don't understand why. It worked fine before I installed "Windows Script
> 5.5"

> /Goofy



Sun, 23 Feb 2003 00:48:04 GMT  
 Installed "Windows Script 5.5" och now I get errormessages.
"Wouter van Eck" wrote ...

Quote:
> Yes, according to the MSDN information it is not possible anymore to add a
> scripting dictionary to an application variable.

Whether or not it was possible before, storing COM objects in session /
application variables has *never* been a good idea...

Adam



Mon, 24 Feb 2003 07:01:53 GMT  
 Installed "Windows Script 5.5" och now I get errormessages.
The dictionary is a 'powerful' object with lots of potential possibilities..

As long as things are possible I like to use it... here is a good solution
to the problem

use this in you global.asa if you want to use the scripting.dictionary in an
application object.
sub Application_onstart
    Dim arrDictObj(0)
    set objDict = server.createobject("scripting.dictionary")
    set arrDictObj(0) = objDictObj
    Application("DictObject") = arrDictObj
end sub

And when you like to use the object in an ASP page use:

    arrDictObj = Application("DictObj")
    set objDict = arrDictObj(0)

If you want to update the Application("DictObj") the use :

Application.lock
    set arrDictObj(0) = objDict
    Application("DictObj") = arrDictObj
Application.unlock

Works for me... I have 'upgraded' all the applications I had with the
dictionary object to this method and haven't had a single problem.

The fun part is, you can store more then one dictionary object in the array
and using only one Application variable...


Quote:
> Well, first, let me say that you shouldn't be using
> the Scripting.Dictionary in an ASP project at
> the application level.

> This would be very bad, espcially if you ever hoped
> of having more than 2 or 3 people hit your site at
> any one given time.

> The Dictionary object was never intended to be used
> as an object for ASP.  The Dict object is and apartment
> model single-threaded application (STA).

> This means that it doesn't scale. It opens up one
> process for all callers. This means that if one person
> is connected to your site and doing some work with the
> dictionary, and someone else connects, they will have to
> wait until the first person is done before they can
> use the dictionary. To make matters worse, if you have
> your web site set to run in-process, it can even tie up
> the whole IIS process and cause the whole web site to
> become unresponsive while dictionary work is being done!

> This would be bad.

> Unfortunately, this situation was made worse by the fact
> that in the NT OptionPack when it installs the Dictionary,
> it marks it as "Both" in the registry which allows IIS
> to use it. This was a huge mistake and caused lots of
> confusion and headaches.

> Visual Studio 6, the new WSH and Windows 2000 all have fixed
> the registry mix-up problem resulting in what you have
> just experienced.

> What can you do then? Well, unfortunately, there's not
> much else you can do. Due to the way dictionaries work,
> it's difficult to engineer it for multiple simultaneous
> access.  If you plan only as using it for read-only access
> (except for the initial population of values during the
> Application_OnStart) you could write your own multi-threaded
> app (MTA) that allows you to have multiple callers. If it's
> Read-Only it shouldn't be that bad, but if you have multiple
> callers adding/removing/updating records, it gets REAL
> complicated and you end up essentially having an in-memory
> database that will need transactional control and mulitple-
> user-access control, etc. It gets REAL complicated. There are
> some COM object R/O dictionaries out there. I can't think of
> one off the top of my head, but I do remember seeing them.

> Writing one shouldn't be too difficult if you only allow
> one population and the rest is all read-only.

> -Chad



> > I recently installed Windows Sript 5.5, and now I get the following
> > errormessage in global.asa when I use this code:

> --------------------------------------------------------------------------
--
> > --------
> > <SCRIPT LANGUAGE=VBScript RUNAT=Server>

> > Sub Application_OnStart
> > Set Application("Pages") = Server.CreateObject("Scripting.Dictionary")
> > Set Application("Host") = Server.CreateObject("Scripting.Dictionary")
> > Set Application("Agent") = Server.CreateObject("Scripting.Dictionary")
> > Set Application("Starttime") =

Server.CreateObject("Scripting.Dictionary")

- Show quoted text -

Quote:
> > Set Application("Is_Logged_in") =
> > Server.CreateObject("Scripting.Dictionary")

> > Application("Logged_in") = 0
> > Application("Last_logged_in") = ""
> > End Sub

> > </SCRIPT>

> --------------------------------------------------------------------------
--
> > --------

> > The errormessage is:

> --------------------------------------------------------------------------
--
> > --------
> > Application object error 'ASP 0197 : 80004005'

> > Disallowed object use

> > /tfw/global.asa, line 4

> > Cannot add object with apartment model behavior to the application
intrinsic
> > object.

> --------------------------------------------------------------------------
--
> > --------

> > I don't understand why. It worked fine before I installed "Windows
Script
> > 5.5"

> > /Goofy



Thu, 27 Feb 2003 11:07:28 GMT  
 Installed "Windows Script 5.5" och now I get errormessages.


Quote:
> The dictionary is a 'powerful' object with lots of potential
possibilities..

> As long as things are possible I like to use it... here is a good solution
> to the problem

> use this in you global.asa if you want to use the scripting.dictionary in
an
> application object.
...

> Works for me... I have 'upgraded' all the applications I had with the
> dictionary object to this method and haven't had a single problem.

Hmmmm.....  That seem to contradict

Q194803 - PRB: Scripting.Dictionary Object Fails in ASP Application Scope
http://support.microsoft.com/support/kb/articles/Q194/8/03.ASP

And also the following

"...Dictionary components [referring to components *other* than the
Scripting.Dictionary as noted later] are also agile objects. The LookupTable
loads its data from a data file and is useful for combo-box data as well as
configuration information. The PageCache object from Duwamish Books provides
dictionary semantics, as does the Caprock Dictionary. These objects, or
derivatives thereof, can form the basis of an effective caching strategy.
Note that the Scripting.Dictionary object is NOT agile, and should not be
stored at Application or Session scope..."

excerpted from

25+ ASP Tips to Improve Performance and Style
http://msdn.microsoft.com/workshop/server/asp/asptips.asp

Adam and Chad weren't talking through their hats...

--
Michael Harris
Microsoft.MVP.Scripting
--



Thu, 27 Feb 2003 11:28:19 GMT  
 Installed "Windows Script 5.5" och now I get errormessages.

"Michael Harris" wrote ...

Quote:
> Adam and Chad weren't talking through their hats...

;-)

Arrays of COM objects at Application level... wouldn't like to see the
real-world performance and scalability of that... :(

hand

Adam



Thu, 27 Feb 2003 17:18:29 GMT  
 Installed "Windows Script 5.5" och now I get errormessages.

I know all the disadvantages... but some how the solution I gave earlier
works and is accepted by the parser.

I don't have the experience nor the tools to prove that it is a bad trick or
a good trick. To be on the safe side ignore my solution earlier ;-)

Wouter



Quote:
> "Michael Harris" wrote ...
> > Adam and Chad weren't talking through their hats...

> ;-)

> Arrays of COM objects at Application level... wouldn't like to see the
> real-world performance and scalability of that... :(

> hand

> Adam



Fri, 28 Feb 2003 20:09:19 GMT  
 Installed "Windows Script 5.5" och now I get errormessages.
"Wouter van Eck" wrote ...

Quote:
> I know all the disadvantages... but some how the solution I gave earlier
> works and is accepted by the parser.

It's not rejected by the compiler because it's perfectly valid ASP - it's
just not a good idea, in general. It might work acceptably for relatively
small numbers of users performing relatively small numbers of operations,
but go beyond that and it will become horribly slow... ASP will only alert
you to syntax errors, not questionable programming styles (if only Steve
Macguire's (sp?) Hypothetical Compiler actually existed ;-)

Quote:
> I don't have the experience nor the tools to prove that it is a bad trick
or
> a good trick. To be on the safe side ignore my solution earlier ;-)

As I said, it depends on exactly what you're doing - it's a bad idea as a
rule of thumb, but there may be some situations where the trade-off between
resource usage, speed and convenience is acceptable.

hth hand

Adam



Sat, 01 Mar 2003 07:58:22 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. "Windows Script Editor", where are you?

2. Windows Script 5.5 downloads "currently unavailable"

3. "Windows 2000 Scripting Bible" support site

4. node.text = val: true gets "-1", false gets "0" at setting node text

5. PostScript Printer "Print-Installed-Fonts" program

6. Enumerating Installed Software "kind of" working

7. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

8. Trapping "Expand", "Open", "Explore" in Windows Explorer?

9. Getting "GhostScript"

10. ASP - getting "Form" variables

11. Getting a "Catastrophic Failure" error

12. ADSI:Getting error on CreateObject("ADsSecurity")

 

 
Powered by phpBB® Forum Software