ErrorPostModule
in ElmahR.Elmah
does not support Winforms apps because it's been written to be an ELMAH module, so it's tied to an ASP.NET lifecycle and cannot be easily adapted. That said, ErrorPostModule
does not do anything so magic and can be easily taken as a guideline to write a small "handler" to be used in a Winforms app. Take a look at its code here, what you should do is:
- replace what's in the OnInit method, which simply reads configuration bits and attaches the error handler
- when an error occurs, handle it like it's done in the
SetError
method to post it to the right destination reading the configuration parameters you read before. You would reference ELMAH and create anError
instance from your exception, and then useErrorJson.EncodeString
to encode it
You may want to borrow the W3.cs file to simplify the http form compilation.
At some point I might generalize this work and put it in ElmahR.Elmah, but not sure when I'll be able to do it.