gpt4 book ai didi

com - asp经典中server.createObject和createobject的区别

转载 作者:行者123 更新时间:2023-12-04 23:10:44 24 4
gpt4 key购买 nike

根据

http://msdn.microsoft.com/en-us/library/ms524620.aspx

你应该使用 server.createObject

If you are already familiar with VBScript or JScript, note that you do not use the scripting language's function for creating a new object instance (CreateObject in VBScript or New in JScript). You must use the ASP Server.CreateObject method; otherwise, ASP cannot track your use of the object in your scripts.



但其他一些人认为 server.createObject 意味着大多数时候可以避免的开销

http://classicasp.aspfaq.com/components/should-i-use-createobject-or-server-createobject.html

CreateObject has less overhead than Server.CreateObject, because the latter uses MTS — causing significant overhead.

You will also suffer performance hits when the component encounters errors, because with Server.CreateObject, these errors are written to the event log (which, admittedly, can be useful during debugging).



或者

http://www.4guysfromrolla.com/webtech/043099-1.shtml

This can become significant if you are writing a component that deals with transactions, as it would be a good safety net to pass it through MTS, because you will be using MTS commands. However, if you are not using MTS, you could create processor and memory over head by passing it through Server.CreateObject. This makes it a better idea to use CreateObject, because it goes straight through.



因此,如果我不使用 mts 并且不需要访问内置 asp 的对象(例如 set d = createObject("scripting.dictionary") )是否可以忘记 server.createObject 并使用 createobject )?

多谢...

最佳答案

你引用的那些文章有些过时了。由于 IIS 5 和 COM+ 在 Windows 2000 及更高版本上使用直 CreateObject与使用 Server.CreateObject 几乎相同.
CreateObject 的 MTS/COM+ 行为或 Server.CreateObject现在是一样的,这部分是因为 ASP 本身作为 COM+ 应用程序运行。您可以指定 ASP 页启动一个事务,然后使用 CreateObject任何实现 IObjectContext 的对象都将被邀请加入事务等。

我所知道的唯一真正的区别是创建的 COM 对象可能具有 OnStartPage 和 OnEndPage 方法的遗留问题。使用 Server.CreateObject这些方法在创建对象时和释放对象之前调用。 CreateObject 不会发生这种情况.

关于com - asp经典中server.createObject和createobject的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1493669/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com