473,770 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception problem

gh
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has some
unexpected behaviours. After adding try-catch block to many pieces of code.
It catches an array index out of bound exception. I am using VS.Net 2003 and
is there any way to avoid this?

Regards,
Aaron
Jul 21 '05 #1
5 1676
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"gh" <gh******@FSAF. COM> wrote in message
news:Oc******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces of
code. It catches an array index out of bound exception. I am using VS.Net
2003 and is there any way to avoid this?

Regards,
Aaron

Jul 21 '05 #2
gh
My program had an array index out of bound problem. I didn't write any
try-catch block to capture this exception. It is supposed that an run time
exception should be thrown and the program terminates. But for my case, it
is not. After adding the try-catch block, the program catches the exception.
"Alvin Bruney [MVP]" <vapor at steaming post office> ¼¶¼g©ó¶l¥ó·s»D: uH************* *@TK2MSFTNGP12. phx.gbl...
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"gh" <gh******@FSAF. COM> wrote in message
news:Oc******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces
of code. It catches an array index out of bound exception. I am using
VS.Net 2003 and is there any way to avoid this?

Regards,
Aaron


Jul 21 '05 #3
Is it possible that the exception is occurring inside of an event handler?
If so, you may have to handle it yourself. In any case, or course, you
should be able to avoid the exception by ensuring that the array size is
never exceeded.
"gh" <gh******@FSAF. COM> wrote in message
news:OU******** ******@TK2MSFTN GP12.phx.gbl...
My program had an array index out of bound problem. I didn't write any
try-catch block to capture this exception. It is supposed that an run time
exception should be thrown and the program terminates. But for my case, it
is not. After adding the try-catch block, the program catches the
exception.
"Alvin Bruney [MVP]" <vapor at steaming post office>
¼¶¼g©ó¶l¥ó·s»D: uH************* *@TK2MSFTNGP12. phx.gbl...
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"gh" <gh******@FSAF. COM> wrote in message
news:Oc******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces
of code. It catches an array index out of bound exception. I am using
VS.Net 2003 and is there any way to avoid this?

Regards,
Aaron



Jul 21 '05 #4
If you don't use a try-catch then when an exception occurs it becomes an
unhandled exception (UE). The behavior of the system is then determined by
the type of thread the UE occurred on. If it is your main thread then the
program will terminate.

"gh" <gh******@FSAF. COM> wrote in message
news:OU******** ******@TK2MSFTN GP12.phx.gbl...
My program had an array index out of bound problem. I didn't write any
try-catch block to capture this exception. It is supposed that an run time
exception should be thrown and the program terminates. But for my case, it
is not. After adding the try-catch block, the program catches the
exception.
"Alvin Bruney [MVP]" <vapor at steaming post office>
¼¶¼g©ó¶l¥ó·s»D: uH************* *@TK2MSFTNGP12. phx.gbl...
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would
you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"gh" <gh******@FSAF. COM> wrote in message
news:Oc******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces
of code. It catches an array index out of bound exception. I am using
VS.Net 2003 and is there any way to avoid this?

Regards,
Aaron



Jul 21 '05 #5
If your program was throwing an exception, and you weren't catching it, how
do you know it was throwing it?

And if you add an exception handler, and the system starts catching an
error, how do you know you didn't ADD the error when you added the exception
handler?

In other words, a CLR bug is far less likely than a bug that you added in
your app when you added exception handling.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"gh" <gh******@FSAF. COM> wrote in message
news:OU******** ******@TK2MSFTN GP12.phx.gbl...
My program had an array index out of bound problem. I didn't write any
try-catch block to capture this exception. It is supposed that an run time
exception should be thrown and the program terminates. But for my case, it
is not. After adding the try-catch block, the program catches the exception.

"Alvin Bruney [MVP]" <vapor at steaming post office>

¼¶¼g©ó¶l¥ó·s»D: uH************* *@TK2MSFTNGP12. phx.gbl...
i'm not sure what you mean by this. the CLR is responsible for executing
code so it exceptions must so it ultimately has to do the throwing. would you mind explaining some more

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------
"gh" <gh******@FSAF. COM> wrote in message
news:Oc******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

Is it true that the CLR sometimes can't throw the run time
exception? Cause I have just encountered a problem that my program has
some unexpected behaviours. After adding try-catch block to many pieces
of code. It catches an array index out of bound exception. I am using
VS.Net 2003 and is there any way to avoid this?

Regards,
Aaron



Jul 21 '05 #6

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

Similar topics

6
2136
by: Páll Ólafsson | last post by:
Hi I have a problem with the Microsoft.ApplicationBlocks.ExceptionManagement? I can't get it to work in RELEASE mode? If I run the project in debug mode the block works fine but when I run the exe file it doesn't catch any errors? Does anyone know what my problem might be? Regards
3
2254
by: Tony Johansson | last post by:
Hello! When you allocate object dynamically which mean on the heap I find that a problem when using exception. What is the prefer method to handle this kind of problem. //Tony
3
2958
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms application that is going to be used to extract data from a legacy system (VSAM based mainframe file structure), and output data in pipe-delimited record layouts, multiple record types per file, one file per chosen client. I have been working on...
16
6592
by: ChInKPoInt [No MCSD] | last post by:
I am using Visual Studio 2K3 writing a ASP.NET web application. Is there a way to force the C# compiler to catch possible exception? In Java, all exceptions thrown MUST BE caught, otherwise compiler would give you error. In C#, is there a way to do that?
44
4228
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box, etc.). 2. Low-level operations that are used to carry out the high level tasks
40
13535
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
5
3437
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
7
2707
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote server returned an error: (500) Internal Server Error." I found a post that suggested to catch the WebException to retrieve the actual HttpWebResponse object for more information. The response returned is shown below. At first I thought this was a...
2
2892
by: Chris Stiefeling | last post by:
Hi, I am experiencing a strange problem. I am reading and writing xml files via XmlDocument and XmlTextWriter. In the debugger everything works fine but outside the debugger (debug or release) I receive the following error: "The type initializer for "System.Xml.Schema.Validator" threw an exception." I wrote a small console app that contains the problem -- I've just attached the default class which gets run. Output outside the...
3
2041
by: Robert Rawlins | last post by:
Hi Mk, Yeah it's got me a little bemused to be honest, I've tried playing around with configuration options this morning and not been able to achieve anything that works properly. I'll keep testing though and as soon as I have a root cause to the problem I'll be sure to let the list know.
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9453
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10036
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8929
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.