Error handling in ActiveX DLL 
Author Message
 Error handling in ActiveX DLL

I am writing an active x dll that will be called from an active server page.
What is the preferred way to pass the errors to the active server page. I
was thinking of raising errors in the object and using an event to notifiy
the calling page. Any tips, source code or links would be appreciated.

J



Tue, 30 Dec 2003 01:02:10 GMT  
 Error handling in ActiveX DLL
You can't generate events into an ASP page. ASP processing is synchronous.
You should catch the errors in your methods and re-raise them up to ASP.

e.g.

Public Sub MyMethod()
    On Error Goto ErrorHandler

    ' Do stuff here

    Exit Sub
ErrorHandler:
    Err.Raise Err.Number,Err.Source,Err.Description
End Sub

Then in your ASP, the error will either be displayed in the page, or if you
set On Error Resume Next, you can check Err.Number in your ASP VBScript.

In addition, I usually change the Err.Raise line to something like the
following:

    Err.Raise Err.Number, "[MyClass::MyMethod] " & Err.Source,
Err.Description

This will give you a stack trace in the Err.Source in addition to the
original error source.

Hope this helps.

Best regards,

Ade.



Quote:
> I am writing an active x dll that will be called from an active server
page.
> What is the preferred way to pass the errors to the active server page. I
> was thinking of raising errors in the object and using an event to notifiy
> the calling page. Any tips, source code or links would be appreciated.

> J



Tue, 30 Dec 2003 01:22:37 GMT  
 Error handling in ActiveX DLL
Can you let me know what you mean by using events to notify the calling
page? ASP does not handle events.

As far as I know, the prefered method to handle errors in ASP is checking
errors after each call into the component that may raise errors. We usually
code in ASP as below:

Dim objCOM

Set objCOM = Server.CreateObject("<ProgID>")

On Error Resume Next
objCOM.<method>

If Err.Number <> 0 Then
        'Handle error here

End If

..

Regards,

Nick



Fri, 02 Jan 2004 16:50:22 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ActiveX DLL Error Handling in VB 5

2. ActiveX DLL Error Handling in VB 5

3. ActiveX DLL Error Handling in VB 5

4. Error handling between ASP and ActiveX dll

5. DLL handle & DLL Function handle

6. Structured exception handling in C ActiveX dll??

7. Error handling in an ActiveX control

8. ActiveX control to handle mouseover event handling?

9. DLL/Class Module Error Handling Advice Needed

10. Errors handling in DLLs

11. Error Handling (Handle by number)

12. Error Handling Is not Handling

 

 
Powered by phpBB® Forum Software