Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a .NET Function that requires a .NET type from Classic ASP

Please Help me.I am trying to over come this paoblem from last 2 days But i am not able to overcome.

I was able to set up the environment so that I can call .NET method (via COM) from a classic ASP page.

Everything actually works as intended until when I have to call a .NET method that requires a .NET type.

So I have a method named SetTable Like Below

I have a function like this in .Net

Public Sub SetTable(ByVal _City As City, ByVal _Country As Country)
          'doing some thing
End Sub

and i have asp code like this:

dim CountryUtil, City, Country
set CountryUtil= Server.CreateObject("mydll.CountryUtil")
set City= Server.CreateObject("mydll.City")
set Country = Server.CreateObject("mydll.Country")
city.id= 123
city.property = "so and so"

Country.id= 123
Country.property = "so and so"

CountryUtil.SetTable(City, Country)

' I get this error here:

'Microsoft VBScript runtime error '800a0005' 'Invalid procedure call or argument: 'SetTable'

Thanks in advance.

like image 471
Avinash Avatar asked Nov 04 '22 17:11

Avinash


1 Answers

in vbscript you only have variants so Country and City are just objects of type variant not of type Country or City.

you will have to change the .net method SetTable (or write a new one) which accepts "variants" (object) and then cast those objects to your .net City and Country objects.

like image 97
ulluoink Avatar answered Nov 09 '22 04:11

ulluoink