473,408 Members | 1,784 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,408 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?
Nov 16 '05 #1
1 1087
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?



Nov 16 '05 #2

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

Similar topics

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...
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...
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: Elmo Watson | last post by:
Up until now, I've done all the work (gui/front end programming, classes, etc) I've done all my error trapping (try/catch) in the methods in the code behind. Now I've got an opportunity to do...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.