问题
I need to call a .Net Class Library from a vbscript application
I have written a C# class library and created a COM DLL component and a type library file
I have successfully registered the dll and tlb on my local computer using
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
I can see them in the windows registry
Now the issue is accessing it in an asp page:
<%@ 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)
80131522
/testdll.asp, line 25
Set cls = Server.CreateObject("Sample.SqlJobs") //SqlJobs is the name of the class
This will be the line 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?
回答1:
You should be using the /codebase
command line switch with regasm
if your assembly is not installed into the GAC.
"...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
来源:https://stackoverflow.com/questions/8128162/need-to-call-a-net-class-library-dll-from-a-classic-asp-page