日期:2014-05-17  浏览次数:20911 次

ASP调用DLL问题
DLL中的函数如下:(工程名:sanzhe1   类名:shuchu)
////////////////////////////////////////////////////////////////////////
Private   MyScriptingContext   As   ScriptingContext
Private   MyApplication   As   Application
Private   MyRequest   As   Request
Private   MyResponse   As   Response
Private   MyServer   As   Server
Private   MySession   As   Session

Public   Sub   OnStartPage(PassedScriptingContext   As   ScriptingContext)
        Set   MyScriptingContext   =   PassedScriptingContext
        Set   MyApplication   =   MyScriptingContext.Application
        Set   MyRequest   =   MyScriptingContext.Request
        Set   MyResponse   =   MyScriptingContext.Response
        Set   MyServer   =   MyScriptingContext.Server
        Set   MySession   =   MyScriptingContext.Session
End   Sub

Private   Sub   printchr(x   As   String)
        MyResponse.Write   (x)
End   Sub

Public   Sub   OnEndPage()
        Set   MyScriptingContext   =   Nothing
        Set   MyApplication   =   Nothing
        Set   MyRequest   =   Nothing
        Set   MyResponse   =   Nothing
        Set   MyServer   =   Nothing
        Set   MySession   =   Nothing
End   Sub


///////////////////////////////////////////////////////////
ASP   代码如下:
///////////////////////////////////////////////////////////
<html>  
<head> <title> 在ASP文件使用DLL </title> </head>  
<body>  
<%  

Set   dice1=Server.Createobject( "sanzhe2.shuchu ")  
call   dice1.printchr()
%>
</body>

//////////////////////////////////////////////////////////////
显示的结果如下:
///////////////////////////////////////////////////////////////
Microsoft   VBScript   运行时错误   错误   '800a01b6 '  

对象不支持此属性或方法:   'printchr '  

/test_dll/test.asp,行   7  


///////////////////////////////////////////////////////////////
我刚开始学,所以请多指教:我的QQ号是:524224465



------解决方案--------------------
printchr是Private的吗?改成Public的试试看
------解决方案--------------------
首先要引用Microsoft Active Server Pages ObjectContext Object Library
才能使用ASP的对象

Private Sub printchr(x As String)
改成
Public Sub printchr(x As String)