主题:[讨论]ASP页面调用VB编写的DLL组件出错问题
本人想尝试一下使用自定义DLL组件来实现ASP代码的功能,这样可以保护自己的核心代码。于是参考资料写了一个测试程序。
首先我用VB6创建了一个ActiveX DLL工程,写完代码后,添加Microsoft Active Server Pages Object对象库,然后编译为Example.dll,类为HelloWorld.cls。
然后使用regsvr32 路径\Example.dll注册该组件
然后写一个index.asp页面,插入如下代码,目的是在页面中显示"Hello World"
<%
Dim ObjReference
Set ObjReference = Server.CreateObject("Example.HelloWorld")
ObjReference.SayHello
%>
可是页面报错详细信息如下:
Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
服务器对象 错误 'ASP 0177 : 800401f3'
Server.CreateObject 失败
/COM/index.asp,行11
无效的 ProgID。 若要获取关于此消息的更多的信息,请访问 Microsoft 联机支持站点: http://www.microsoft.com/contentredirect.asp 。
请问这是怎么回事?代码我检查了N遍了,不会有错的。急等各位大侠帮助
附录---DLL程序代码
'////////////////////类变量声明模块///////////////////////
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
'页面销毁函数
Public Sub OnEndPage()
Set MyscriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
End Sub
'HelloWorld功能函数
Public Sub SayHello()
MyResponse.Write ("Hello World")
End Sub
首先我用VB6创建了一个ActiveX DLL工程,写完代码后,添加Microsoft Active Server Pages Object对象库,然后编译为Example.dll,类为HelloWorld.cls。
然后使用regsvr32 路径\Example.dll注册该组件
然后写一个index.asp页面,插入如下代码,目的是在页面中显示"Hello World"
<%
Dim ObjReference
Set ObjReference = Server.CreateObject("Example.HelloWorld")
ObjReference.SayHello
%>
可是页面报错详细信息如下:
Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
服务器对象 错误 'ASP 0177 : 800401f3'
Server.CreateObject 失败
/COM/index.asp,行11
无效的 ProgID。 若要获取关于此消息的更多的信息,请访问 Microsoft 联机支持站点: http://www.microsoft.com/contentredirect.asp 。
请问这是怎么回事?代码我检查了N遍了,不会有错的。急等各位大侠帮助
附录---DLL程序代码
'////////////////////类变量声明模块///////////////////////
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
'页面销毁函数
Public Sub OnEndPage()
Set MyscriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
End Sub
'HelloWorld功能函数
Public Sub SayHello()
MyResponse.Write ("Hello World")
End Sub