主题:[讨论]为什么带有窗体的DLL在ASP中无法调用?
一个很简单的例子:编译成TestDLLwithPic.dll,类名testPic
[code=vb]
Option Explicit
Dim mfrm As Form1 '主要是为了利用form1里的picturebox控件画图
Private Sub Class_Initialize()
Set mfrm = New Form1
End Sub
Private Sub Class_Terminate()
Set mfrm = Nothing
End Sub
Public Function showMsg() As String
showMsg = "this is a project to test pictureboxs in dll"
End Function
Public Function exportpicture(ByVal strpath As String)
mfrm.Picture1.AutoRedraw = True '不设置此属性时,在vb里调用时都会出错
mfrm.Picture1.Print "demo print method"
mfrm.Picture1.Circle (mfrm.Picture1.Width / 2, mfrm.Picture.Height / 2), mfrm.Picture1.Width / 3
SavePicture mfrm.Picture1.Image, strpath
End Function
[/code]
在asp里:
[code=vb]
<%
Dim ojbpic
Set objpic=Server.CreateObject("TestDLLwithPic.TestPic")
Response.write objpic.showmsg
objpic.exportpicture Server.mappath("../testpic.bmp")
Response.write "<img src=" & Chr(34) & "../testpic.bmp?id=" & Rnd() & Chr(34) & ">"
%>
[/code]
运行时发生错误:
错误类型:
Active Server Pages, ASP 0115 (0x80004005)
外部对象中发生了可捕获的错误(C0000005)。脚本无法继续执行。
/test/testpic.asp
[url=http://bbs.pfan.cn/post-290511.html] asp调用DLL,外部对象中发生了可捕获的错误(C0000005)。脚本无法继续执行。 [/url]
这个dll在VB里是可以正常使用的.
在VB里,
[code=vb]
Private Sub Command1_Click()
Dim a As Object
Set a = CreateObject("testdllwithpic.testpic")
Debug.Print a.showmsg
a.exportpicture "e:\jsh.bmp"
Picture1.Picture = LoadPicture("e:\jsh.bmp")
End Sub
[/code]
[code=vb]
Option Explicit
Dim mfrm As Form1 '主要是为了利用form1里的picturebox控件画图
Private Sub Class_Initialize()
Set mfrm = New Form1
End Sub
Private Sub Class_Terminate()
Set mfrm = Nothing
End Sub
Public Function showMsg() As String
showMsg = "this is a project to test pictureboxs in dll"
End Function
Public Function exportpicture(ByVal strpath As String)
mfrm.Picture1.AutoRedraw = True '不设置此属性时,在vb里调用时都会出错
mfrm.Picture1.Print "demo print method"
mfrm.Picture1.Circle (mfrm.Picture1.Width / 2, mfrm.Picture.Height / 2), mfrm.Picture1.Width / 3
SavePicture mfrm.Picture1.Image, strpath
End Function
[/code]
在asp里:
[code=vb]
<%
Dim ojbpic
Set objpic=Server.CreateObject("TestDLLwithPic.TestPic")
Response.write objpic.showmsg
objpic.exportpicture Server.mappath("../testpic.bmp")
Response.write "<img src=" & Chr(34) & "../testpic.bmp?id=" & Rnd() & Chr(34) & ">"
%>
[/code]
运行时发生错误:
错误类型:
Active Server Pages, ASP 0115 (0x80004005)
外部对象中发生了可捕获的错误(C0000005)。脚本无法继续执行。
/test/testpic.asp
[url=http://bbs.pfan.cn/post-290511.html] asp调用DLL,外部对象中发生了可捕获的错误(C0000005)。脚本无法继续执行。 [/url]
这个dll在VB里是可以正常使用的.
在VB里,
[code=vb]
Private Sub Command1_Click()
Dim a As Object
Set a = CreateObject("testdllwithpic.testpic")
Debug.Print a.showmsg
a.exportpicture "e:\jsh.bmp"
Picture1.Picture = LoadPicture("e:\jsh.bmp")
End Sub
[/code]