Need to call a .Net Class library dll from a Classic ASP Page

2

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?

.net
vbscript
asp-classic
com-interop
class-library
asked on Stack Overflow Nov 14, 2011 by Lakshmi • edited Nov 14, 2011 by Joel Coehoorn

1 Answer

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

answered on Stack Overflow Nov 14, 2011 by Matt Wilko

User contributions licensed under CC BY-SA 3.0