[英]Need to call a .Net Class library dll from a Classic ASP Page
I need to call a .Net Class Library from a vbscript application 我需要从vbscript应用程序调用.Net类库
I have written a C# class library and created a COM DLL component and a type library file 我已经编写了C#类库并创建了COM DLL组件和类型库文件
I have successfully registered the dll and tlb on my local computer using 我已经使用以下方法在本地计算机上成功注册了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"
The dll and the type library file are registered successfully dll和类型库文件已成功注册
I can see them in the windows registry 我可以在Windows注册表中看到它们
Now the issue is accessing it in an asp page: 现在问题是在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>
When I run this file I got the following error 当我运行此文件时,出现以下错误
The page cannot be displayed
该页无法显示
I am getting an error 我收到一个错误
Error Type:
错误类型:
Server object, ASP 0177 (0x80131522)服务器对象,ASP 0177(0x80131522)
8013152280131522
/testdll.asp, line 25/testdll.asp,第25行
Set cls = Server.CreateObject("Sample.SqlJobs") //SqlJobs is the name of the classSet cls = Server.CreateObject(“ Sample.SqlJobs”)// SqlJobs是类的名称
This will be the line 25这将是第25行
The server Instance is not getting created未创建服务器实例
Can anyone please help me figure out where I am going wrong and suggest me possible ways of fixing this issue? 谁能帮助我找出问题所在,并向我提出解决此问题的可行方法?
You should be using the /codebase
command line switch with regasm
if your assembly is not installed into the GAC. 如果您的程序集未安装在GAC中,则应该在
/codebase
命令行开关中使用regasm
。
"...The Codebase entry specifies the file path for an assembly that is not installed in the global assembly cache..." - have a look at this link for more info “ ...代码库条目指定了未安装在全局程序集缓存中的程序集的文件路径...”-有关更多信息,请查看此链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.