描述:
用
GetActiveObject
RegisterActiveObject
RevokeActiveObject
的方法不行
因为脚本语言不能调用API
怎么办呀?
解决方案1:
你在首页创建这个对象,然后把这个对象保存到Session里面,以后调用时调用这个Session就是了。比如
set objCatcher=GetObject("BookView.Document")
Session("MyObj") = objCatcher
以后使用 Session("MyObj") 就是了
再写个COM对象,让脚本通过这个对象得到你想要的单件对象。这样你就可以用C++来实现单件了。
像这样:
creator = new ActiveXObject("BookView.Creator");
Document = creator.CreateDocument();
在CreateDocument函数里用GetActiveObject返回你的BookView.Document对象就行了。
将组件缓存在Session里会极大地影响IIS的效率,微软明确反对这种做法,CSDN文档里有翻译。
应该用Singleton实现。
You can treat the new ActiveXObject as a new alias of an existing object, attach to the object and redirect all operation to it.
///////////////////////
呵呵,典型的Singleton模式
脚本语言里不能缓存对象吗?
解决方案6:You can treat the new ActiveXObject as a new alias of an existing object, attach to the object and redirect all operation to it.