tags:

views:

59

answers:

2

Hi,

When I try to run some VB6 code, I get the following error:

Microsoft VBScript runtime error: Invalid procedure call or argument: 'stx.ResolveAddress'

However, in the code below, if I do NOT set the return to "stx.ResolveAddress" to a variable, I do NOT get the above error.

Set stx = CreateObject("MyApp.Api.Wse3.STxTransactionService")
Set addr = CreateObject("MyApp.Api.Wse3.Address")
addr.Address1 = "1850 Table Mesa Dr"
addr.Address2 = "Boulder, CO 80305"
stx.ResolveAddress(addr)

However, if I change that last line to look like this instead:

result = stx.ResolveAddress(addr)

I get the the "Invalid procedure call" error. Is there something I'm missing? Why does the assignment cause the error to happen?

A: 
stx.ResolveAddress(addr)

is incorrect syntax in VB6. Using brackets around arguments is only for functions. You have to remove the brackets, or add a Call or return a variable:

stx.ResolveAddress addr

or

Call stx.ResolveAddress(addr)

or

foo = stx.ResolveAddress(addr)

This is why you are getting different results for when you assign a variable and when you dont.

If you are calling a .Net dll and running from the ASP environment, make sure that the .Net dll is installed correctly in the GAC (VB6 runtime environment has some magic that allows non-GAC'd .Net DLL's run). Either the DLL has to be in the GAC or it has to RegAsm'd and installed in the same directory as running application (not sure about classic ASP, but my guess is that it has to run in the same DLL as the classic ASP process).

Kris Erickson
Kris, when I try running something like "foo = stx.ResolveAddress(addr)", that's when I get the "Invalid procedure call" error. Is there another way, I should be assigning "foo"?
justinvbeltran
@Kris: I think he's using the correct variable assignment syntax in the example `result = stx.ResolveAddress(addr)`. The DLL seems to be found by asp because the call without the return value succeeds.
Eric J.
EDIT: Kris, so looking at some logging generated by the DLL, it appears that "stx.ResolveAddress(addr)" without the assignment to a variable DOES get called.
justinvbeltran
What is the type of "result" that is being returned? Next thought is that it should be set result = stx.ResolveAddress(addr) where result is an object. Can you post the signature in .Net of the ResolveAddress function?
Kris Erickson
Do you mean something along the lines of "Dim result As Object", "result = stx.ResolveAddress(addr)"? The .NET signature is "public ResolveAddressResult ResolveAddress(Address a)". Nothing too complicated.
justinvbeltran