加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

com – asp经典中的server.createObject和createobject之间的区

发布时间:2020-12-16 07:21:24 所属栏目:asp.Net 来源:网络整理
导读:根据 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 (C
根据

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就可以了吗?

非常感谢…

解决方法

你引用的那些文章有点过时了.由于使用直接CreateObject的Windows 2000及更高版本上的IIS 5和COM与使用Server.CreateObject几乎相同.

CreateObject或Server.CreateObject的MTS / COM行为现在是相同的,这部分是由于ASP本身作为COM应用程序运行的事实.您可以指定ASP页面启动事务然后使用CreateObject任何实现IObjectContext的对象将被邀请加入事务等.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读