I assume that you mean that you are declaring a class member of type MAPIFolder
something like:
public class MyOutlookClass {
private MAPIFolder mapiFolder = <some method of getting a folder>;
}
The answer is you can't put error handling around this. You have to put
error handling around the code which creates the class:
try {
MyOutlookClass xx = new MyOutlookClass();
} catch....
However the error will prevent then instance being actually created, and
if you're writing an add-in then you don't have control over the creating
code anyway. So don't do this.
Declare the variable, but don't assing it to anything. In the Class Constructor,
set it to whatever you want and you can handle the error there as appropriate.
If you are writing an add-in, the any unhandled error which escapes your
code and gets back to Outlook will not hang your code, but will stop Outlook
calling you addin again which can look like it's hung.
Hang out in some of the Outlook groups - microsoft.public.developer.outlook.addins
or microsoft.public.outlook.program_addins for instance - and you'll similar
advice and more that you'll need.
Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook
On 19 Jun 2004 21:12, "J. A. Bailo" wrote:
I wrote an Outlook InterOp program.
One of the declarations assigning a MAPI folder to a variable, throws an
error if an instance of Operator is left open.
That is not the problem.
The problem is, the program will then hang. In a method, I could
enclose the code in a try/catch block.
How do I implement error handling here?