当前位置: 代码迷 >> ASP >> VB写的DLL在ASP里调用时报“未设置对象变量或 With block 变量”异常
  详细解决方案

VB写的DLL在ASP里调用时报“未设置对象变量或 With block 变量”异常

热度:959   发布时间:2012-03-06 20:47:55.0
VB写的DLL在ASP里调用时报“未设置对象变量或 With block 变量”错误
小弟写的这个DLL结构如下:
Name= "MyDLL "
两个类:
Class=x;   x.cls
Class=y;   y.cls
没有公共类

其中:Class=x;   x.cls   代码如下:
Public   ScriptingContext   As   ScriptingContext
Public   Application   As   Application
Public   Request   As   Request
Public   Response   As   Response
Public   Server   As   Server
Public   Session   As   Session

Public   Sub   OnStartPage(PassedScriptingContext   As   ScriptingContext)
        Set   ScriptingContext   =   PassedScriptingContext
        Set   Application   =   ScriptingContext.Application
        Set   Request   =   ScriptingContext.Request
        Set   Response   =   ScriptingContext.Response
        Set   Server   =   ScriptingContext.Server
        Set   Session   =   ScriptingContext.Session
End   Sub
Public   Sub   OnEndPage()
        Set   ScriptingContext   =   Nothing
        Set   Application   =   Nothing
        Set   Request   =   Nothing
        Set   Response   =   Nothing
        Set   Server   =   Nothing
        Set   Session   =   Nothing
End   Sub

Public   Function   f1(   str   )
        Response.Write   str
End   Function

Class=y;   y.cls   代码如下:
Public   ScriptingContext   As   ScriptingContext
Public   Application   As   Application
Public   Request   As   Request
Public   Response   As   Response
Public   Server   As   Server
Public   Session   As   Session

Public   Sub   OnStartPage(PassedScriptingContext   As   ScriptingContext)
        Set   ScriptingContext   =   PassedScriptingContext
        Set   Application   =   ScriptingContext.Application
        Set   Request   =   ScriptingContext.Request
        Set   Response   =   ScriptingContext.Response
        Set   Server   =   ScriptingContext.Server
        Set   Session   =   ScriptingContext.Session
End   Sub
Public   Sub   OnEndPage()
        Set   ScriptingContext   =   Nothing
        Set   Application   =   Nothing
        Set   Request   =   Nothing
        Set   Response   =   Nothing
        Set   Server   =   Nothing
        Set   Session   =   Nothing
End   Sub

Public   Function   f1(   str   )
      f1   =   x.f1(   str   )
End   Function

ASP调用:
<%
dim   mydll
set   mydll   =   Server.CreateObject( "MyDLL.y ")
mydll.f1   "AAAAA "
  相关解决方案