Can I use progID with TypeLib instead of UUID?

P

Peter X

Hi all,

Quick question - in my Global.asa I'm using code like this:

<!--METADATA TYPE="TypeLib" NAME="Microsoft Scripting Runtime"
UUID="{420B2830-E718-11CF-893D-00A0C9054228}" VERSION="1.0"-->

Whereas in Windows Scripting Host .WSF files, I can use this:

<reference object="Scripting.FileSystemObject" />

Since UUID's are rather unfriendly, is it possible to use the prodID
with ASP instead?

Any related comments appreciated - TIA!
 
M

Manohar Kamath [MVP]

Peter,

You are including a type library ID (from what I know, always a GUID), and
not a prog ID. This is because you are not creating any object, and hence
have to include the unfriendly GUIDs :)

However, you can use an OBJECT tag, to create a object that lives across the
session or Application:

<OBJECT RUNAT=Server SCOPE=Session ID=MyObj PROGID="My.Class">
</OBJECT>

And use the reference MyObj in all your pages. Just make sure that the
object is safe-threaded -- call from one page does not block the call from
another.

I think this is a bad practice, since you can not guarantee the state of the
object, the chances of thread-blocking is very high.
 
P

Peter X

Manohar said:
Peter,

You are including a type library ID (from what I know, always a GUID), and
not a prog ID. This is because you are not creating any object, and hence
have to include the unfriendly GUIDs :)

But really I'm doing the same in ASP as I'm doing in Windows Scripting Host!

Going on the documentation for the <reference> element, you can either
use a GUID or a prodID... so once I'd read this, tried it, and found it
worked, I though it would be nice to be able to do the same in ASP.

Heres a link to the <reference> docs:

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/wsh/htm/wsEleReference.asp

However, you can use an OBJECT tag, to create a object that lives across the
session or Application:

<OBJECT RUNAT=Server SCOPE=Session ID=MyObj PROGID="My.Class">
</OBJECT>

And use the reference MyObj in all your pages. Just make sure that the
object is safe-threaded -- call from one page does not block the call from
another.

I think this is a bad practice, since you can not guarantee the state of the
object, the chances of thread-blocking is very high.

Mmmm.. I might avoid that! :)

I can continue using GUID's with ASP, but like I say I was just using
<reference> for the first time and though, "oh, thats nice".


Anyay Manohar, thanks loads for the reply!!
 
R

Ray at

Yes, and I believe some would say that doing so is more efficient, as the
ASP engine will use late binding to create your objects. Here's some sample
code:

<object progID="Scripting.Filesystemobject" id="oFSO"
runat="server"></object>

<%
Set oFile = oFSO.OpenTextFile("C:\file.txt")
Response.Write Server.HTMLEncode(oFile.ReadAll)
oFile.Close : Set oFile = Nothing
%>

Ray at hotel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top