VB6 dll 在 VB6 应用程序中工作,而不是在 ASP 中工作
我正在用 asp 开发一个旧项目 在我成为 .net 开发人员之前,我从未使用过 vb6 或 asp
无论如何,
我制作了一个 .net dll 并更改了一些编译选项以使其与 vb6 一起使用 代码并不重要
我在vb6中创建了一个“包装器有点”dll
Public Function EncryptWrapper(ByVal parameterstring As String, ByVal isShaIn As String, ByVal HashType As String) As String
Dim o
Set o = CreateObject("SHA1Module.Conversion")
EncryptWrapper = CStr(o.EncryptToSHA1(CStr(parameterstring), CBool(isShaIn), CLng(HashType)))
End Function
,并在vb6中创建了一个调用它的表单,
Private Sub Command1_Click()
Dim message
Dim myObject
Set myObject = CreateObject("SHAModuleWrapper.Encryption")
message = myObject.EncryptWrapper(txtIn.Text, "1", "2")
Set myObject = Nothing
txtOut.Text = message
End Sub
现在在asp中完美运行
我尝试调用该dll,我得到一个错误,
<% Dim strMessage
Dim message
strMessage = "hello"
Dim myObject
Set myObject = Server.CreateObject("SHAModuleWrapper.Encryption")
message = myObject.EncryptWrapper("testdagtestdagtest", "1", "0")
Response.Write(message)
%>
这是错误消息
SHAModuleWrapper错误'800a0005'
无效的过程call or argument
/asptest/Default.asp, line 15
这不是参数或输出 正是这部分造成了麻烦
**Dim o
Set o = CreateObject("SHA1Module.Conversion")
EncryptWrapper = CStr(o.EncryptToSHA1(CStr(parameterstring), CBool(isShaIn), CLng(HashType)))**
有人有想法吗?
I'm working on an old project in asp
I've never worked with vb6 or asp before I am a .net developer
anyway
I made a .net dll and changed some compile options to make it work with vb6
the code doesnt matter
I made a "wrapper kinda" dll in vb6
Public Function EncryptWrapper(ByVal parameterstring As String, ByVal isShaIn As String, ByVal HashType As String) As String
Dim o
Set o = CreateObject("SHA1Module.Conversion")
EncryptWrapper = CStr(o.EncryptToSHA1(CStr(parameterstring), CBool(isShaIn), CLng(HashType)))
End Function
and a form in vb6 that calls it
Private Sub Command1_Click()
Dim message
Dim myObject
Set myObject = CreateObject("SHAModuleWrapper.Encryption")
message = myObject.EncryptWrapper(txtIn.Text, "1", "2")
Set myObject = Nothing
txtOut.Text = message
End Sub
this works perfectly
now in asp I try calling that dll and I get an error
<% Dim strMessage
Dim message
strMessage = "hello"
Dim myObject
Set myObject = Server.CreateObject("SHAModuleWrapper.Encryption")
message = myObject.EncryptWrapper("testdagtestdagtest", "1", "0")
Response.Write(message)
%>
this is the error message
SHAModuleWrapper error '800a0005'
Invalid procedure call or argument
/asptest/Default.asp, line 15
It's not the parameters or the output
it's this part that is causing the trouble
**Dim o
Set o = CreateObject("SHA1Module.Conversion")
EncryptWrapper = CStr(o.EncryptToSHA1(CStr(parameterstring), CBool(isShaIn), CLng(HashType)))**
Does anybody have an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这些线路令人担忧。这些将是一个变体,因为它们不是定义的类型。
Option Explicit
是您在 VB6 中的朋友 - 始终使用它!看看这个链接: 使用 Option Explicit 语句避免 VB6 中的程序错误了解更多信息。
These lines are cause for concern. These will be a variant as they are not a defined type.
Option Explicit
is your friend in VB6 - use it always!Have a look at this link: Avoid program bugs in VB6 with the Option Explicit statement for more information.
经过一番折腾和批处理文件后我找到了解决方案。
我需要为我的程序集创建一个强名称并在 GAC 中注册它
这是关于如何解决此问题的一个很好的分步教程
教程
这两个步骤帮助了我
8)生成公钥/私钥对
9) 将属性添加到我的程序集中以进行注册:
A lot of frustration and batch files later I found the solution.
I needed to create a strong name for my assembly and register it in the GAC
This is a good step by step tutorial on how to solve this issue
Tutorial
these 2 steps helped me
8) Generate a public/private key pair
9) Add the attribute to my assembly for registering it:
在你的错误代码中你有
Set o = CreateObject("SHA1Module.Conversion")
应该是
Set o = CreateObject("SHA1Module.Encryption")
in your bad code you have
Set o = CreateObject("SHA1Module.Conversion")
should it be
Set o = CreateObject("SHA1Module.Encryption")
检查 IUSR_机器 是否有权执行您的 dll。
Check that IUSR_Machine has permission to execute your dlls.