【发布时间】:2011-12-29 00:20:34
【问题描述】:
我需要从 vbscript 应用程序调用 .Net 类库
我编写了一个 C# 类库并创建了一个 COM DLL 组件和一个类型库文件
我已经使用
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