Handling exceptions in a Word COM add-in (C#)

A

Alex

Hello,

It is possible to have a single location for handling exceptions in a ..NET application by adding a handler to System.Windows.Forms.Application.ThreadException.

I tried to do it in my Word IDTExtensibility2 add-in but it did not catch the exceptions.

Is there a way to make it work?

Thanks,
Alex.
 
H

Helmut Obertanner

Hello Alex,

in my projects i use a Logger class where i have a static funtion LogError.

If you do so, you can call Logger.LogError(....)
In my case the Logger writes to Application EventLog.

But there are 1000 ways to handle it.
There is also a Microsoft Application Block.
But i found it's too heavy for my suits.

--
Freundliche Grüße / with regards.

Helmut Obertanner
Technical Consultant

Softwaredevelopment
DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich
web: www.datalog.de


.... and IT works!

Hello,

It is possible to have a single location for handling exceptions in a .NET
application by adding a handler to
System.Windows.Forms.Application.ThreadException.

I tried to do it in my Word IDTExtensibility2 add-in but it did not catch
the exceptions.

Is there a way to make it work?

Thanks,
Alex.
 
A

Alex

Helmut Obertanner said:
Hello Alex,

in my projects i use a Logger class where i have a static funtion LogError.

If you do so, you can call Logger.LogError(....)
In my case the Logger writes to Application EventLog.

But there are 1000 ways to handle it.
There is also a Microsoft Application Block.
But i found it's too heavy for my suits.

Hello Helmut,

Thank you for your reply but this is not what I was looking for.

I am trying to catch all exceptions in one place (instead of having several try/catch blocks in my add-in).
I can do it in a Windows Forms application using System.Windows.Forms.Application.ThreadException but it does not work in a IDTExtensibility2 add-in.
 
H

Helmut Obertanner

Hello Alex,

don't beleive it's possible, cause you are in loaded as COM AddIn in
Outlook.exe process,
not in a Windows Forms Application.

--
Freundliche Grüße / with regards

Helmut Obertanner
Technical Consultant

Softwaredevelopment
DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich
web: www.datalog.de


.... and IT works!

Helmut Obertanner said:
Hello Alex,

in my projects i use a Logger class where i have a static funtion
LogError.

If you do so, you can call Logger.LogError(....)
In my case the Logger writes to Application EventLog.

But there are 1000 ways to handle it.
There is also a Microsoft Application Block.
But i found it's too heavy for my suits.

Hello Helmut,

Thank you for your reply but this is not what I was looking for.

I am trying to catch all exceptions in one place (instead of having several
try/catch blocks in my add-in).
I can do it in a Windows Forms application using
System.Windows.Forms.Application.ThreadException but it does not work in a
IDTExtensibility2 add-in.
 
A

Alex

Hello Helmut,

Helmut Obertanner said:
Hello Alex,

don't beleive it's possible, cause you are in loaded as COM AddIn in Outlook.exe process,
not in a Windows Forms Application.

Thanks.
I figured as much but hoped that there is some mechanism to achieve similar functionality.

Best wishes,
Alex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top