473,387 Members | 1,597 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,387 software developers and data experts.

Try/Catch problem

Hello,
I have the following code:

try
{
Salarii.Editors.AngajatiNewFrm _angNewFrm = new
Salarii.Editors.AngajatiNewFrm();
_angNewFrm.Connection = this.Connection;
_angNewFrm.ShowInTaskbar = false;
_angNewFrm.ShowDialog();
_angNewFrm.Dispose();
}
catch ( Exception ex )
{
Salarii.Exceptions.ExceptionFrm frm = new
Salarii.Exceptions.ExceptionFrm();
frm.Exc = ex;
frm.ShowDialog();
frm.Dispose();
}

This only a part from a big project.
My problem is that: if I run the application from Visual Studio than if
there is an error in try block than the exception is catch and my
Exceptions Form is displayed, but if I run the generated executable and
I produce the same error in try block than my Exception form is NOT
displayed. I am talking about the same error! I tried to put a
MessageBox in catch block, but is displayed only if I run from Visual
Studio.

Can somebody help me with this?

Thanks in advance!
Best regards,
O

Jun 29 '06 #1
4 1851
O,

I would guess that an exception is being thrown in the catch block. I
would put some code around there to determine what is going on.

Also, you might want to use the using statement as well. There is no
reason you should have to manually call Dispose on either of the forms.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bad_boyu" <si************@gmail.com> wrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Hello,
I have the following code:

try
{
Salarii.Editors.AngajatiNewFrm _angNewFrm = new
Salarii.Editors.AngajatiNewFrm();
_angNewFrm.Connection = this.Connection;
_angNewFrm.ShowInTaskbar = false;
_angNewFrm.ShowDialog();
_angNewFrm.Dispose();
}
catch ( Exception ex )
{
Salarii.Exceptions.ExceptionFrm frm = new
Salarii.Exceptions.ExceptionFrm();
frm.Exc = ex;
frm.ShowDialog();
frm.Dispose();
}

This only a part from a big project.
My problem is that: if I run the application from Visual Studio than if
there is an error in try block than the exception is catch and my
Exceptions Form is displayed, but if I run the generated executable and
I produce the same error in try block than my Exception form is NOT
displayed. I am talking about the same error! I tried to put a
MessageBox in catch block, but is displayed only if I run from Visual
Studio.

Can somebody help me with this?

Thanks in advance!
Best regards,
O

Jun 29 '06 #2

try
{
Salarii.Editors.AngajatiNewFrm _angNewFrm = new
Salarii.Editors.AngajatiNewFrm();
_angNewFrm.Connection = this.Connection;
_angNewFrm.ShowInTaskbar = false;
_angNewFrm.ShowDialog();
_angNewFrm.Dispose();
}
catch ( Exception ex )
{
try
{ Salarii.Exceptions.ExceptionFrm frm = new
Salarii.Exceptions.ExceptionFrm();
frm.Exc = ex;
frm.ShowDialog();
frm.Dispose();

}
catch (Exception anotherEx)
{
MessageBox.Show(anotherEx.Message);
} }
You'll probably find it like this.............. (aka, put a second
try/catch)
You can also write up a "starter" EntryPoint class like this:

Add a new Class .. called EntryPoint.cs

public class EntryPoint
{

public static void Main(string[] args)
{
try
{
Application.Run (new MainApplicationStartupForm());
}
catch (Exception ex)
{
MessageBox.Show("Unhandled exception: " + ex.Message);
}
}
}
You'll be able to recover better using the EntryPoint.cs class.

"bad_boyu" <si************@gmail.com> wrote in message
news:11*********************@75g2000cwc.googlegrou ps.com... Hello,
I have the following code:

try
{
Salarii.Editors.AngajatiNewFrm _angNewFrm = new
Salarii.Editors.AngajatiNewFrm();
_angNewFrm.Connection = this.Connection;
_angNewFrm.ShowInTaskbar = false;
_angNewFrm.ShowDialog();
_angNewFrm.Dispose();
}
catch ( Exception ex )
{
Salarii.Exceptions.ExceptionFrm frm = new
Salarii.Exceptions.ExceptionFrm();
frm.Exc = ex;
frm.ShowDialog();
frm.Dispose();
}

This only a part from a big project.
My problem is that: if I run the application from Visual Studio than if
there is an error in try block than the exception is catch and my
Exceptions Form is displayed, but if I run the generated executable and
I produce the same error in try block than my Exception form is NOT
displayed. I am talking about the same error! I tried to put a
MessageBox in catch block, but is displayed only if I run from Visual
Studio.

Can somebody help me with this?

Thanks in advance!
Best regards,
O

Jun 29 '06 #3
Thanks, I am going to try your solutions!

Jun 29 '06 #4
One other place to look...
what if the bug is in the dialog form itself.

It is entirely possible that your form load event has some bug in it that
doesn't show up in VS but does show up in an EXE environment. In that case,
the form is being called, but it errors out before it can show. Since you
are already in the last statements of a catch block, you wouldn't see the
effect. It would appear as though the form never opened.

Look in your code for the form itself.

--
--- 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.
--
"bad_boyu" <si************@gmail.com> wrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Hello,
I have the following code:

try
{
Salarii.Editors.AngajatiNewFrm _angNewFrm = new
Salarii.Editors.AngajatiNewFrm();
_angNewFrm.Connection = this.Connection;
_angNewFrm.ShowInTaskbar = false;
_angNewFrm.ShowDialog();
_angNewFrm.Dispose();
}
catch ( Exception ex )
{
Salarii.Exceptions.ExceptionFrm frm = new
Salarii.Exceptions.ExceptionFrm();
frm.Exc = ex;
frm.ShowDialog();
frm.Dispose();
}

This only a part from a big project.
My problem is that: if I run the application from Visual Studio than if
there is an error in try block than the exception is catch and my
Exceptions Form is displayed, but if I run the generated executable and
I produce the same error in try block than my Exception form is NOT
displayed. I am talking about the same error! I tried to put a
MessageBox in catch block, but is displayed only if I run from Visual
Studio.

Can somebody help me with this?

Thanks in advance!
Best regards,
O

Jun 30 '06 #5

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

Similar topics

6
by: Erik Cruz | last post by:
Hi. I have read several articles recommending avoid to raise exceptions when possible, since exceptions are expensive to the system. Removing code from Try... Catch blocks can help performance?...
4
by: nrhayyal | last post by:
hi all, i am facing a problem in catching an exception which is uncaught in any of the catch block. not doing so will gives me coredump. I tried by rewriting set_unexpected() and set_terminate()...
10
by: Bungle | last post by:
Hi I am trying to do something really simple. Create a method within a class which will connect to the database, pull back a result and return it out the method. Not hard. All my database...
11
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
9
by: Mark | last post by:
Hello I'm trying to use a Server.Transfer in a try-catch (I cannot put it outside the Try-Catch as it is nested deep within a component that is called in a try-catch loop) The problem is that the...
7
by: Tiraman | last post by:
Hi , I am using allot the try catch in my code and the question is if it is good ? it will decrease my performance ? one more question
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.