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 Functio开发者_高级运维n
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?
Dim o
Dim message
Dim myObject
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.
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
sn -k MarkItUp.key
9) Add the attribute to my assembly for registering it:
<Assembly: AssemblyKeyFile("C:\MarkItUp.key")>
in your bad code you have
Set o = CreateObject("SHA1Module.Conversion")
should it be
Set o = CreateObject("SHA1Module.Encryption")
Check that IUSR_Machine has permission to execute your dlls.
精彩评论