asp.net - 从经典 ASP 调用需要 .NET 类型的 .NET 函数

标签 asp.net vb.net asp-classic

请帮助我。我正在努力克服过去 2 天的这个问题,但我无法克服。

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

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

所以我有一个名为 SetTable 的方法如下

我在 .Net 中有一个这样的功能

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

我有这样的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)

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

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

提前致谢。

最佳答案

在 vbscript 中,您只有变体,因此 Country 和 City 只是变体类型的对象,而不是 Country 或 City 类型。

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

关于asp.net - 从经典 ASP 调用需要 .NET 类型的 .NET 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6923157/

相关文章:

asp-classic - VB : how to get the index(es) of an array element if used in For Each

c# - 我应该开始学习 ASP Classic 还是 'continue' 学习 ASP.NET?

javascript - 在 jQuery 中用 TAB 键代码替换 Enter 键代码

java - VB.NET/Java 上的图表

vb.net - 将月份名称转换为整数

html - asp表格问题

ASP.NET - View 状态大小

asp.net - 如何在业务逻辑层实现事务

c# - Asp.net的AutoEventWireup和反射?

c# - ListBox 中的 WrapPanel 具有水平和垂直滚动功能