473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error Trapping in class declarations

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?
Jul 21 '05 #1
1 1237
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?



Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JP | last post by:
I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
1
by: J. A. Bailo | last post by:
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...
2
by: Captain Nemo | last post by:
I'm still using Office 2000 myself, but some of my clients have Office 2003. I've recently added a piece of code to create an instance of Word, open a document, fill in the blanks and become...
9
by: 47computers | last post by:
Pretty new to PHP, I recently started learning about error trapping. As of right now, I include the following into a page in my website: -------BEGIN PASTE-------- error_reporting(E_ERROR |...
1
by: petschy | last post by:
hello, i've run into an error when qualifying a copy ctor 'explicit'. the strange thing is that i get a compiler error only if the class is a template and declare the variable as X<Zx = y....
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.