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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

POP3 ASP Component - ActiveX DLL with WinSock

Status
Not open for further replies.

LCD

MIS
Feb 19, 2001
72
US
I created a DLL that allows me to access a POP3 account with ASP. It works on my computer (WinXP Pro) using the LocalHost webserver. BUT when I put it on our Win2k Web Server I get a message saying "Can't Create Object".

I'm using the same ASP and DLL that works on my machine.

Is anyone familiar with how to resolve this?? Thanks =)
Andrew

Misc Info:

Server = Win2k Server w/ sp2
The Webserver is Set to allow Scripts & Executables
The NTFS Security is good
DLL IS Registered
Windows Script 5.6 Installed
IE6 Installed

-----[Begin Error Message]---------------------------------

ASPCONX error '800a01ad'

ActiveX component can't create object

/wap/test.asp, line 4

-----[END Error Message]-----------------------------------

Below is the Code

Project = AspConx
ClassModule = Mail

-----[Begin DLL]-------------------------------------------

Option Explicit
'Some code borrowed from WnsckFormDLL

Private WithEvents WSock As Winsock
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim output, Username1, Password1, Site1 As String

Private Sub Class_Initialize()
Set WSock = New Winsock
End Sub

Private Sub Class_Terminate()
If WSock.State = 7 Then WSock.Close
Do
Pause (500)
Loop While WSock.State = 7
Set WSock = Nothing
End Sub

Public Function GetMyMail(Username As String, Optional Password _
As String, Optional Site As String, Optional Port As String)

output = "User: " & Username & vbCrLf
Username1 = Username
Password1 = Password
Site1 = Site
With WSock
If .State <> 0 Then
.Close
Do
Loop Until .State = 0
End If
.RemoteHost = Site
.RemotePort = Port
.Connect
Do
Pause (500)
Loop Until .State > 6
Select Case .State
Case 9
output = output & &quot;Error Connecting To Server - Case 9<br>&quot;
Case 8
output = output & &quot;Error Connecting To Server - Case 8<br>&quot;
Case 7
output = output & &quot;Connected To Server!&quot; & vbCrLf
ReadLine
Login
GetLast
.SendData &quot;Quit&quot; & vbCrLf
Pause (500)
End Select
End With
GetMyMail = &quot;<textarea name=&quot;&quot;txtarea&quot;&quot; rows=&quot;&quot;25&quot;&quot; cols=&quot;&quot;80&quot;&quot;>&quot; _
& output & &quot;</textarea><br>&quot;
End Function

Private Sub ReadLine()
Dim InData As String
Dim intTimeOut As Integer
intTimeOut = 0
InData = &quot;&quot;
Do
intTimeOut = intTimeOut + 1
WSock.GetData InData
If intTimeOut > 12 And InData = &quot;&quot; Then InData = _
&quot;ERROR - Timeout Occured After &quot; & intTimeOut / 2 & &quot; Seconds.&quot;
If InData = &quot;&quot; Then Pause (500)
Loop While InData = &quot;&quot;
output = output & InData & vbCrLf
End Sub

Private Sub Login()
WSock.SendData &quot;USER &quot; & Username1 & vbCrLf
output = output & &quot;USER &quot; & Username1 & vbCrLf
ReadLine
WSock.SendData &quot;PASS &quot; & Password1 & vbCrLf
output = output & &quot;PASS &quot; & Password1 & vbCrLf
ReadLine
End Sub

Private Sub GetLast()
Dim InData As String
Dim intTimeOut As Integer
Dim strLastMsg As String
Dim intLastMsg As Integer
WSock.SendData &quot;LAST&quot; & vbCrLf
intTimeOut = 0
InData = &quot;&quot;
Do
intTimeOut = intTimeOut + 1
WSock.GetData InData
If intTimeOut > 12 And InData = &quot;&quot; Then InData = _
&quot;ERROR - Timeout Occured After &quot; & intTimeOut / 2 & &quot; Seconds.&quot;
If InData = &quot;&quot; Then Pause (500)
Loop While InData = &quot;&quot;
strLastMsg = Mid$(InData, 4)
intLastMsg = CInt(strLastMsg)
intLastMsg = intLastMsg + 1
output = output & &quot;Getting Message &quot; & intLastMsg & vbCrLf
WSock.SendData &quot;RETR &quot; & intLastMsg & vbCrLf
ReadLine
End Sub


Private Sub Pause(Interval As Long)
Dim Start
Start = GetTickCount
Do While GetTickCount < Start + Interval
DoEvents
Loop
End Sub

-----[End DLL]---------------------------------------------

-----[Begin ASP]-------------------------------------------

Line 01: <html><body>
Line 02: <%
Line 03: dim strOutput, objMailDll
Line 04: set objMailDll = Server.CreateObject(&quot;AspConx.Mail&quot;)
Line 05:
Line 06: strOutput = objMailDll.GetMyMail(&quot;UserName&quot;, &quot;Password&quot;, &quot;MailAddr.com&quot;, &quot;110&quot;)
Line 07:
Line 08: response.Write strOutput & &quot;<br>&quot;
Line 09: set objMailDll = Nothing
Line 10: %>

-----[End ASP]---------------------------------------------
 
your answer is right in the HTML

It can't create AspConx.Mail

That means that its not registered.
 
Thats also what I thought at first, but I've registered the DLL multiple times now.
Andrew
 
OK

I found this in the Knowledge base.

SYMPTOMS
The use of CreateObject to create a COM component in an Active Server Pages (ASP) page may result in the following error:

Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object
This error is usually generated because dynamic-link libraries (DLLs) on which the COM object depends are one of the following:
Missing from the system


Not in the system path


Not accessible by the system because of security settings





MORE INFORMATION
Each of the above reasons applies to the DLL that implements the COM object as well as any of the DLLs dependencies. For instance, if a COM DLL statically links to a Win32 DLL and the Win32 DLL is missing from the system, a 800a01ad error is generated.

There are many ways to determine DLL dependencies. Among these are the Depends.exe tool, which shipped with the Platform Software Development Kit (SDK) and Developer Studio 98, and the DUMPBIN utility, which is installed with Visual C++. You can down the Depends.exe tool from the following Microsoft Web site:

To use Depends, simply run the tool and open the DLL in question. To use DUMPBIN to view the dependencies, run the following at a command prompt &quot;dumpbin /IMPORTS <name of DLL>&quot;. The Depends utility has the advantage of displaying dependencies of dependencies. It would appear that quick view in the Windows Explorer would display the same information, but it has been observed that the information displayed is not always complete.

Further information about each of the possible causes follows:

DLLs Missing From the System
The DLL that implements the COM object must exist on the system and be registered with the correct path. Creation failure of a COM object that is not registered at all will actually generate a different error:

Server object error 'ASP 0177 : 800401f3'

To verify that the path in the registry is correct, run the RegEdit program and search for the PROGID (found in the CreateObject call). From the PROGID entry, record or copy the CLSID to the Clipboard and locate the entry for the CLSID. This entry should contain an InprocServer32 key with a path to the DLL. The following illustrates the flow of this process:


(from the asp file)
set obj = Server.CreateObject(&quot;BadComponent.Badguy&quot;) (from RegEdit)
HKEY_CLASSES_ROOT\BadComponent.BadGuy\CLSID
{683DA7E0-5C73-11D2-80F6-0000F87A8236} HKEY_CLASSES_ROOT\CLSID\{683DA7E0-5C73-11D2-80F6-0000F87A8236}\
InprocServer32 E:\Programs\COMPON~1\BADCOM~1\Debug\BADCOM~1.DLL

The following commands run from a command prompt will verify the existence of this file:


E:\>cd E:\Programs\COMPON~1\BADCOM~1\Debug
E:\Programs\COMPON~1\BADCOM~1\Debug>dir BADCOM~1.DLL 10/14/98 11:18a 241,739 BadComponent.dll 1 File(s) 241,739 bytes
2,038,755,328 bytes free

If no path is specified in the registry for the DLL, the DLL must exist in the system path.

A COM DLL may have dependencies other than Win32 DLLs that are statically linked (DUMPBIN and Depends.exe show DLLs statically linked). For instance, a COM object may call LoadLibrary() and call functions in a Win32 DLL. Similarly, the control may create COM objects that are contained in separate DLLs. Any of these DLLs may be missing, improperly registered, on inaccessible due to security. This would result in a runtime error that may or may not be encountered during the creation of the control. Returning S_FALSE from the FinalConstruct() method of an ATL control can simulate an example of control failing in such a manner during creation. This assumes LoadLibrary() or CoCreateInstance() failed in FinalConstruct(), and the programmer chose to check for this and return S_FALSE. The error generated in this case will be similar to the following:

error 'ASP 0115'
Unexpected error
/badguy.asp
A trappable error occurred in an external object. The script cannot
continue running.
Server object error 'ASP 0115 : 8000ffff'

Failure of this type will not generate an 800a01ad error.


DLLs Not in the System Path
The system must be able to find the dependant DLLs (statically linked) of the DLL that implements the COM object being created. Using DUMPBIN or Depends, determine what the dependent DLLs are. Verify that all of these DLLs are either in the same directory as the COM DLL or in the system path.

DLLs Not Accessible by the System Because of Security Setting
When a client requests an Active Server Pages (ASP) page from a server, the ASP page runs in a security context dependant on the authentication method used to access the Web Server. For instance, anonymous requests run in the context of the IUSR_MACHINENAME where MACHINENAME is the name of your computer. For information on other authentication methods and security considerations, please consult the IIS documentation. What this means in terms of an 800a01ad error is that the authenticated user must have access (via NTFS file permissions) to the COM DLL and all of the dependant DLLs.

A shotgun approach can be used to determine if this is the cause of the problem. Using the Windows Explorer, select Properties for the COM DLL, select the Security tab, and grant &quot;everyone&quot; at least read access to the DLL. Do the same for the dependent DLLs and directories containing the DLLs. This should eliminate any security restrictions that may be affecting the creation of the COM object. Security can be tightened after it is determined that this was the problem. Keep in mind, many of the dependant DLLs are Windows system DLLs and will have at least &quot;everyone read&quot; access already. Do not mistakenly remove this access when &quot;tightening&quot; the security.

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Robert E. Duke, Microsoft Corporation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top