【问题标题】:Need to call a .Net Class library dll from a Classic ASP Page需要从经典 ASP 页面调用 .Net 类库 dll
【发布时间】:2011-12-29 00:20:34
【问题描述】:

我需要从 vbscript 应用程序调用 .Net 类库
我编写了一个 C# 类库并创建了一个 COM DLL 组件和一个类型库文件
我已经使用

在本地计算机上成功注册了 dll 和 tlb
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe 
  "C:\user\Visual Studio 2008\Projects\[Sample]\[Sample]\bin\Debug\[Sample].dll" 
  /tlb "C:\user\Visual Studio 2008\Projects\[Sample]\[Sample]\bin\Debug\[Sample].tlb"

dll和类型库文件注册成功
我可以在 Windows 注册表中看到它们

现在的问题是在 asp 页面中访问它:

<%@  Language=VBScript %>
<html> 
<body>
<%


dim cls
dim myDevelopmentDBConn

Set myDevelopmentDBConn = Server.CreateObject("ADODB.Connection")
With myDevelopmentDBConn
.Provider = "SQLNCLI"
.ConnectionString = "user ID=abc;password=abc;Initial Catalog=TestLdb;Data         
 Source=sqlservername"
.ConnectionTimeout = 600
.CommandTimeout = 600
.Open
 End With
Response.Write  myDevelopmentDBConn
Set myDevelopmentDBConn =nothing
Set cls = Server.CreateObject("Sample.SqlJobs") 'SqlJobs is the name of the class 
Response.Write cls

'Response.Write "<b>" & cls.UpdateSqlJob("Test1","sqlservername", "abc", "abc" ) & "</b>"

'Test1=sqlserverjob name
'abc-username
'abc-password
Set cls =nothing
%>

</body>

</html>

当我运行这个文件时,我得到了以下错误

页面无法显示

我收到一个错误

错误类型:
服务器对象,ASP 0177 (0x80131522)
80131522
/testdll.asp,第 25 行
Set cls = Server.CreateObject("Sample.SqlJobs") //SqlJobs是类的名字
这将是第 25 行
未创建服务器实例

谁能帮我找出哪里出错并建议我解决此问题的可能方法?

【问题讨论】:

标签: .net vbscript asp-classic com-interop class-library


【解决方案1】:

如果您的程序集未安装到 GAC 中,您应该使用 /codebase 命令行开关和 regasm。

“...Codebase 条目指定了未安装在全局程序集缓存中的程序集的文件路径...” - 查看this link 了解更多信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-04
    • 2019-01-29
    • 1970-01-01
    • 2013-06-30
    • 1970-01-01
    • 1970-01-01
    • 2012-12-29
    • 2010-09-05
    相关资源
    最近更新 更多