Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COM implementation? 2

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
I created a .dll in VB6. It's very simple, this is all there is to it...
____________________________________
Option Explicit

Public Function doit()
MsgBox ("Testing"), vbOKOnly, "Application Test"
End Function

____________________________________

I also published it to the server. However, now that the .dll has been created, and it's in on the computer, how to I implement it for use in the .asp page? What do I need to do to be able to use the "doit()" function by calling it from the asp code?
-Ovatvvon :-Q
 
Hi,
Before you can use a COM object (or DLL), you will need to register it on the server with regsvr32.exe After that, you should be able to create an object for it:

set myFunctions as server.createObject( "thenameofthedll" )
call myFunction.doit()

However, note that the function actually creates a message box. And since this code is executed on the server, you won't be able to see anything on the client (browser) end ...

regards,
- Joseph
====================
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Shopping --> , Soccer --> ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 
I think I remember that. That's where I have to type in the command prompt: c:\>regsvr32 nameOfDll.dll ?

If I ever want to deregister it in the future, how would I do that? -Ovatvvon :-Q
 
I registered the dll and set the following code into the page:


<%
set myFunctions = server.createObject( &quot;doit.dll&quot; )
call myFunctions.doit()
%>

using &quot;as&quot; didn't work because this is classic asp. In vb or asp.net it would've worked. I changed it to &quot;=&quot;. Also, I'm pretty sure you meant to type myFunctions.doit() and not myFunction.doit(), so I changed that as well.

However, it still doesn't work. This is the error that is printed by the page:
____________________________________

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/doit.asp, line 5

Invalid ProgID. For additional information specific to this message please visit the Microsoft Online Support site located at:
And just for kicks, I tried the following without adding the &quot;.dll&quot; after the name:

set myFunctions = server.createObject( &quot;doit&quot; )

but it had the same effect.

What am I doing wrong? -Ovatvvon :-Q
 
Hi,
Sorry for the typos :eek:( Anyway, to de-register, use:
regsvr32 /u yourDLLname

Assuming the name of your dll file is &quot;myFunctions.dll&quot;
then:
1. regsvr32 myFunctions.dll (execute this is Command Prompt).
2. in your code:
set myFunctions = server.createObject( &quot;myFunctions&quot; )
call myFunctions.doit()

regards,
- Joseph
==================== ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Shopping --> , Soccer --> ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 
First of all, thank you for taking the time to help me out!

I registered the dll &quot;doit.dll&quot; which is in my root web directory. In the code on my page, the entire page reads as such:

______________________

<%

set myFunctions = server.createObject( &quot;doit&quot; )
call myFunctions.doit()

%>
______________________

But it won't work. The page is located at if you wanted to see the page with the error.


-Ovatvvon :-Q
 
Hi ovatvvon,
Sorry, I was skipping too much and missed too much :eek:( Brain not functioning today :eek:(

1. Create an ActiveX EXE project name myDLL.dll:
class myFunctions
public function doIt()
doIt = &quot;Testing 123&quot;
end function
end class

2. Compile and register it: regsrv32 myDLL.dll
3. in your ASP:
<%
set myFunc= server.createObject( &quot;myDLL.myFunctions&quot; )
Response.Write( myFunc.doit() )
%>

You can get a copy of the myDLL.dll from:
-->
regards,
- Joseph
====================== ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Shopping --> , Soccer --> ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 
I tried with a ActiveX EXE, but it won't let me make a dll file with it...only an exe. So instead my tried with an ActiveX DLL...

I saved the class as myDllClass.cls, and the project as myDLL.vbp. I inserted the code you said into the class...

class myFunctions
public function doIt()
doIt = &quot;Testing 123&quot;
end function
end class

however, when I try to do &quot;make myDLL.dll&quot; from the file menu, I get the following error, &quot;Compile error: Invalid outside procedure&quot; with the &quot;myFunctions&quot; title highlighted.

If I try taking out the &quot;class myFunctions&quot; and &quot;end class&quot; and just run the doit() function inside the class module myDLLClass.cls so the code inside reads:
_______________________________
Option Explicit

Public Function doIt()
doIt = &quot;Testing 123&quot;
End Function
_______________________________


Then I can make and register the myDLL.dll file, but the web page still looks the same...like it did originially.

What am I doing wrong?

You can download a zip file with my project at to see if I'm making the project / dll file wrong. I'm sure that's probably what it is.
-Ovatvvon :-Q
 
Ovatvvon,

In VB, make the name of your Project &quot;myDll&quot; (you can do this in the properties box - the Name Property) and the name of your class &quot;myClass&quot; (again, using the Name Property). Then register it as fhlee suggsted.

Then, in ASP, you would call it like so:

<%
set myFunc = server.createObject(&quot;myDLL.myClass&quot;)
Response.Write myFunc.doIt
%>

It all has to do with the name of the project and the class, not the file name(s). This should work without any problem. Let me know if it doesn't. HTH. Insanity is merely a state of mind while crazy people have a mind of their own.
 
It works now. Thank you very much, both of you!!! -Ovatvvon :-Q
 
One more problem I've run into though. If I've published and registered the DLL and I continue to make updates...it won't let me remake the DLL file...it says &quot;Access Denied&quot;. I've tried de-registering it, and I've tried closing Visual Basic all together and restarting it again, but it still won't. I have to shut down the computer and restart it again for me to update the DLL each time.

Is there an easier way to go about this? -Ovatvvon :-Q
 
The reason why this is happening is because one of the system/software is using the DLL. A good practise is that once you compile a DLL, do not register it on the same location. Copy it to another place and then register that. Also, make sure you close off all programs and shutdown IIS ...

regards,
- Joseph
================= ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Shopping --> , Soccer --> ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top