devxlogo

Reference a DLL From an ASP Page

Reference a DLL From an ASP Page

Question:

I wrote a DLL in Visual Basic and I want to use its functions in ASP. I created a server.CreateObject(“projectname.classname”) and tried to call some of the methods of the object, but received “Automation error Invalid syntax.” How do I use the object’s methods?

Answer:

Once you create the DLL in VB, you need to copy it to the Web server machine and then register it. Use the utility RegSvr32.EXE found in your Windows directory to register your DLL.

RegSvr32 will register a DLL.
RegSvr32 /U will unregister a DLL.

Once you do that, you can access it by using the code you have:

set objSomething = Server.CreateObject("projectname.classname")

Then call its method (say MethodCall) by using:

objSomething.Methodcall

Finally, remove the object from memory:

set objSomething = Nothing

devx-admin

Share the Post: