ASP code using DLL from VB.NET
ASP code using DLL from VB.NET
am 03.10.2006 14:59:06 von Michael Jahnz
This post is a modifed version of one I made to the interop section (on
09.29.2006) but no one replied... since the question is partially about ASP
this group may be appropriate. Any help you could offer would be much
appreciated!!
I need help getting some VB.NET code (via a DLL) to work with classic ASP to
perform HMACSHA1 processing / validation. I already have the HMACSHA1 code
working as VB.NET code.
I've created VB.NET (ApplicationType is Class Library) code using Visual
Studio 2005, that can calculate a HMAC hash, Base64Encode the result, and
return the value... The Visual Studio 2005 project has the checkbox for
interop selected in the project properties section. The VB.NET code is as
follows (and does work correctly):
Namespace HMAC_HELPER
Public Class HMAC_HELPER
Public Sub New()
End Sub
Private Function ConvertStringToByteArray(ByVal stringToConvert)
Dim ue As New System.Text.UnicodeEncoding
Return ue.GetBytes(stringToConvert)
End Function
Public Function getHash(ByVal stringToHash, ByVal stringHashKey)
Dim sha As New
System.Security.Cryptography.HMACSHA1(ConvertStringToByteArr ay(stringHashKey))
Dim data As Byte()
Dim hashValue As Byte()
Dim returnValue As String
data = ConvertStringToByteArray(stringToHash)
hashValue = sha.ComputeHash(data)
returnValue = Convert.ToBase64String(hashValue)
Return returnValue
End Function
End Class
End Namespace
I need the ability to access the above code from a DLL file via Classic ASP
like this:
Classic ASP Code:
....
Dim Obj
Set Obj = Server.CreateObject("HMAC_HELPER")
newHashValue = Obj.getHash(aString, hashKey)
Obj = nothing
....
I have used the redasm.exe and gacutil to register the assembly, but cannot
get the ASP code to recognize the DLL file "HMAC_HELPER".
Would someone please explain the steps I need (or missed) to get this
working, as the ASP code has no idea what the "HMAC_HELPER" is. I get the
following error from classic asp:
Server object, ASP 0177 (0x800401F3)
Invalid class string
Any help or direction would be much appreciated. If an alternative approach
exists, I'd be interested in learning about it.
Thank you.
-Michael
Re: ASP code using DLL from VB.NET
am 03.10.2006 15:09:51 von Mike
"Michael Jahnz" wrote in message
news:OM872uu5GHA.668@TK2MSFTNGP02.phx.gbl...
> This post is a modifed version of one I made to the interop section (on
> 09.29.2006) but no one replied... since the question is partially about
> ASP this group may be appropriate.
Ummm wrong again, I'm afraid. Ths group covers classic asp. The one you
want for dotnet is at microsoft.public.dotnet.framework.aspnet.
--
Mike Brind
Re: ASP code using DLL from VB.NET
am 03.10.2006 15:10:37 von Patrice
I would remove the namespace statement and would use
.HMAC_HELPER for the classid.
Else your best bet is likely to just have a look at the registry to see what
is the exact registered classid. For now I would think that the classid
string used from ASP is not correct...
Good luck.
--
Patrice
"Michael Jahnz" a écrit dans le message de news:
OM872uu5GHA.668@TK2MSFTNGP02.phx.gbl...
> This post is a modifed version of one I made to the interop section (on
> 09.29.2006) but no one replied... since the question is partially about
> ASP this group may be appropriate. Any help you could offer would be much
> appreciated!!
>
> I need help getting some VB.NET code (via a DLL) to work with classic ASP
> to perform HMACSHA1 processing / validation. I already have the HMACSHA1
> code working as VB.NET code.
>
> I've created VB.NET (ApplicationType is Class Library) code using Visual
> Studio 2005, that can calculate a HMAC hash, Base64Encode the result, and
> return the value... The Visual Studio 2005 project has the checkbox for
> interop selected in the project properties section. The VB.NET code is as
> follows (and does work correctly):
>
> Namespace HMAC_HELPER
> Public Class HMAC_HELPER
> Public Sub New()
> End Sub
>
> Private Function ConvertStringToByteArray(ByVal stringToConvert)
> Dim ue As New System.Text.UnicodeEncoding
> Return ue.GetBytes(stringToConvert)
> End Function
>
> Public Function getHash(ByVal stringToHash, ByVal stringHashKey)
> Dim sha As New
> System.Security.Cryptography.HMACSHA1(ConvertStringToByteArr ay(stringHashKey))
> Dim data As Byte()
> Dim hashValue As Byte()
> Dim returnValue As String
> data = ConvertStringToByteArray(stringToHash)
> hashValue = sha.ComputeHash(data)
> returnValue = Convert.ToBase64String(hashValue)
> Return returnValue
> End Function
> End Class
> End Namespace
>
>
> I need the ability to access the above code from a DLL file via Classic
> ASP like this:
> Classic ASP Code:
> ...
> Dim Obj
> Set Obj = Server.CreateObject("HMAC_HELPER")
> newHashValue = Obj.getHash(aString, hashKey)
> Obj = nothing
> ...
>
>
> I have used the redasm.exe and gacutil to register the assembly, but
> cannot get the ASP code to recognize the DLL file "HMAC_HELPER".
>
> Would someone please explain the steps I need (or missed) to get this
> working, as the ASP code has no idea what the "HMAC_HELPER" is. I get the
> following error from classic asp:
> Server object, ASP 0177 (0x800401F3)
> Invalid class string
>
>
> Any help or direction would be much appreciated. If an alternative
> approach exists, I'd be interested in learning about it.
>
> Thank you.
> -Michael
>
>
Re: ASP code using DLL from VB.NET
am 03.10.2006 15:12:10 von Mike
"Mike" wrote in message
news:OcG%2310u5GHA.1248@TK2MSFTNGP03.phx.gbl...
> "Michael Jahnz" wrote in message
> news:OM872uu5GHA.668@TK2MSFTNGP02.phx.gbl...
>> This post is a modifed version of one I made to the interop section (on
>> 09.29.2006) but no one replied... since the question is partially about
>> ASP this group may be appropriate.
>
> Ummm wrong again, I'm afraid. Ths group covers classic asp. The one you
> want for dotnet is at microsoft.public.dotnet.framework.aspnet.
>
Opps. Sorry. Didn't read all of your post....
Re: ASP code using DLL from VB.NET
am 27.10.2006 09:54:34 von unknown
I tried this with Visaul Studio 2003, but if I try the same with VS 2005, I am getting the error msg "Invalid class string " ..any ideas
rgds,
Sri
Re: ASP code using DLL from VB.NET
am 27.10.2006 09:54:45 von unknown
I tried this with Visaul Studio 2003, but if I try the same with VS 2005, I am getting the error msg "Invalid class string " ..any ideas
rgds,
Sri