Access 2000 VBA with .net Framework 2.0 issue

G

gardenofsimple

Hi everyone!

I just wanted some opinions before I gave up on this solution
altogether and found another way. I know that there are many ways to
solve this problem, it's just that this one seemed simple and elegant
(until it didn't work!)

The givens are that a) I must use Access 2000 and b) I am stuck
with .net Framework 2.0. I cannot upgrade either of these products.
I'm sorry. I realize that upgrading both would most likely solve this
instantly.

So: working within these constraints, what I wanted to do was write a
very short VBA module to encrypt a few strings using the SHA512
algorithm.

I wanted to use the SHA512 class from the System.Security.Cryptography
namespace:
http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha512(VS.80).aspx

However, I can't get it to work.

1) I can add mscorlib.dll as a reference.
2) I can create an instance of SHA512 -- Dim x As New SHA512

The problem occurs when I try to use the ComputeHash method. The code
y = x.ComputeHash(z) causes VBA to return the runtime error "Invalid
procedure call or argument".

When I look at the SHA512 class in Object Browser, it contains no
members. This is really puzzling to me.

So my question is: why would the Object Browser show no members and
yet VBA is willing to let me create an instance of this class?

Is there something simple I'm missing here? Or is this never going to
work.

Thanks for your help.

C.
 
G

gardenofsimple

As you found out: it don't work that way. VBA cannot use .NET
assemblies directly.
In a similar situation we wrote a .NET assembly and gave it a COM
wrapper. THEN you can reference that DLL from Access and call its
public interface.

-Tom.
Microsoft Access MVP

Tom thank you SO much for pointing me in the right direction. I
thought I was going to go mad from not being able to figure out why.

C.
 
D

David H

FYI - Sounds like for what you're doing moving to a later version of Access
is a moot point. Also, all of the various versions of Access are releases
with a freely downloadable & redistributable (sp?) version of Access. There
are some limits with the runtime version, but for the most part they
shouldn't be an issue. In short, the only up-front cost to move to a new
version of Access is the copy that you'll need for development.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top