Using a DLL in your ASP Application

Friday, September 7, 2012

tags ASP

ASP allows for the use of external DLLs for your web applications. The DLL that you integrate generally includes code that was compiled in either VB, or C++. The ability to introduce external code into your web application is useful in scenarios where certain functionality is needed in your application and someone has already written the code that you need. Once you introduce the DLL into your web application, you will be able to create instances of the objects defined in the DLL so that you can access the properties and methods of the objects of interest.

Register the DLL

Prior to accessing the objects that reside in the DLL file, you must first register the DLL with the Windows Runtime Library.

Register via regsvr32

  1. Place the DLL file AspEmail.dll in a directory on the server, note the path for step 2
  2. Register it using the regsvr32 command-line utility: c:\>regsvr32 myDLL.dll
  3. If you receive a confirmation message that the process has been completed, no other steps are required.

Unregister via regsvr32

  1. Unregister it using the regsvr32 command-line utility: c:\>regsvr32 /u myDLL.dll
  2. The DLL file is not required so you can safely delete it from the file system.

Using the DLL in your Application

After you have registered the DLL with the operating system, the next step is to access the procedures that are contained within it. In this example, the DLL that was registered is called myDLL.dll. Within the DLL, there is a class called myClass. To create an instance of this class you would use the Server.CreateObject method as follows:

Dim myObj
myObj = Server.CreateObject("myDLL.myClass")
myObj = nothing

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

ASP In A Nutshell Sams Teach Yourself Active Server Pages 3.0 in 21 Days Beginning ASP Databases