开发者

Invalid procedure calling .NET DLL method via COM in Classic ASP

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?


I had what seems to be the exact same problem that was resolved by adding an extra pair of brackets around the argument passed to the problematic function, like so:

result = stx.ResolveAddress((addr))

There is a discussion on this on 4guysfromrolla.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜