70235

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 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?

Answer1:

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

Recommend

  • How to prevent cross domain issues by proxying in IIS?
  • Performance difference between accessing local and class member variables
  • Access PCF DEV from external machine on same network as host
  • What dll is needed for Windows.Devices.Geolocation?
  • not able to create VC++ project, with VS11
  • How to format code on aptana 3?
  • Visual studio 2015 keystroke with mouse button
  • Upgrade project from WorkLight 6.1 to MobileFirst 7.1
  • TFS - how do I sum child task hours to parent
  • Deploying a CodeRush plugin from the Community Site
  • How to pass solution folder as parameter in command line arguments (for debug)?
  • C# List of Panels
  • Does Apportable support to build library binary (.a/.so)?
  • How to return DataSet (xsd) in WCF
  • Reading a file into a multidimensional array
  • Android application: how to use the camera and grab the image bytes?
  • Do I need to reset a Perl hash index?
  • Custom validator control occupying space even though display set to dynamic
  • How to clear text inside text field when radio button is select
  • Scrapy recursive link crawler
  • Display issues when we change from one jquery mobile page to another in firefox
  • Different response to non-authenticated users and AJAX calls
  • Apache 2.4 and php-fpm does not trigger apache http basic auth for php pages
  • Sony Xperia Z Tablet not found by adb
  • VS2008 Enable C++ Exception with SEH
  • Javascript convert timezone issue
  • htaccess rewriting URLs with multiple forward slashes
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Display Images one by one with next and previous functionality
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Web-crawler for facebook in python
  • Why winpcap requires both .lib and .dll to run?
  • Data Validation Drop Down Box Arrow Disappearing
  • A cron job substitute?
  • json Serialization in asp
  • How do you join a server to an Active Directory (domain)?
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal