从Classic ASP调用需要.NET类型的.NET函数

Avi*_*ash 5 vb.net asp.net asp-classic

请帮助我.我试图过去2天来这个问题但是我无法克服.

我能够设置环境,以便我可以从传统的ASP页面调用.NET方法(通过COM).

一切都按预期工作,直到我必须调用需要.NET类型的.NET方法.

所以我有一个名为SetTable Like Below的方法

我在.Net中有这样的功能

Public Sub SetTable(ByVal _City As City, ByVal _Country As Country)
          'doing some thing
End Sub
Run Code Online (Sandbox Code Playgroud)

我有像这样的asp代码:

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)
Run Code Online (Sandbox Code Playgroud)

'我在这里得到这个错误:

'Microsoft VBScript运行时错误'800a0005''无效的过程调用或参数:'SetTable'

提前致谢.

ull*_*ink 2

在 vbscript 中,您只有变体,因此国家/地区和城市只是变体类型的对象,而不是国家/地区或城市类型。

您必须更改 .net 方法 SetTable (或编写一个新方法),该方法接受“变体”(对象),然后将这些对象转换为您的 .net City 和 Country 对象。