|
Here is a blog I use from time to time
Brad Abrams blog
try
{
screwed up stuff
}
catch(ArgumentException ex)
{stuff catcher}
catch(PathTooLongException ex)
{more stuff}
catch(Exception ex)
(the catch all stuff)
finally
{This always gets hit}
|
|
|
|
|
Thanks for you reply
I have good understanding of how to catch and deal with exceptions. What I'm looking for is what type of exceptions are thrown.
I might not have been clear enough. I'm basically looking for class documentation that explicitly declares what exceptions are thrown - Similar to the Java API.
Cheers
|
|
|
|
|
Quinten.Miller wrote: I'm basically looking for class documentation that explicitly declares what exceptions are thrown - Similar to the Java API.
.NET Class Library[^]
Each method is documented with the types of exceptions it throws. For example, the documentation for the Random class's Next(int maxValue)[^] method states that it will throw an ArgumentOutOfRangeException if maxValue is less than zero.
|
|
|
|
|
Hi Leslie
The .NET Class Library is what I'm looking for. I guess I will have to get use to the different way of dealing with code that causes exceptions.
Thanks heaps for you help
Cheers
Q
|
|
|
|
|
You could use reflection to view the methods. You can also catch Exception, which catches all. You should avoid this. Generally, the exceptions will be obvious ( FileNotFound for a delete method, for example ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Other than looking at the documentation (and trusting that it has been fully documented) there aren't any tools (at least none that I'm aware of) that will generate a list of exceptions.
It would be possible using a tool like Reflector[^], but that would be a very manual process.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Visual Studio 2003 has this problem. However, Visual Studio 2005 does list the exceptions for the method call. Just hover your mouse over the method name for a moment.
Phil
|
|
|
|
|
Cheers
Looks like VS2005 is the way to go
Thanks for this info
|
|
|
|
|
Hi
I think you can solve your problem as below:
Put All the statements of your method in a Try-Catch.
for example:
private void divisionOperator()
{
try
{
result = result / x ;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Nima_e
|
|
|
|
|
Thanks for your reply
Not really a good idea to use a catch all exception if you don't have to. Better in this case to use a NumberFormatException (from memory). Catching a plain exception can cause other problems like hiding an exception that you might not have thought possible to throw.
For better explanation have a read of this article: Exception Handling Best Practices in .NET[^]
Cheers
Q
|
|
|
|
|
I think it's a shame that checked exceptions weren't implemented in c#. I love them.
Here's a link that discusses why they were left out of c#
http://www.artima.com/intv/handcuffs.html
HTH
Russell
-- modified at 8:26 Wednesday 11th April, 2007
|
|
|
|
|
hello!!
i have a problem.
i did a report by crystal reports, when the query is simple no have problem, the application search the report and it appears, but when i have a query with
ex:
SELECT *
FROM Categories
INNER JOIN Products
ON Categories.CategoryID = Products.CategoryID
the application search the report but before it appears, the DataBase Login screen appears first.
How i do to decide it!
thanks a lot!
|
|
|
|
|
hi,
I don't know where your database located. If your db is in server machine using SQl server, you must provide an accessing permission in Enterprise Manager with Security item.
It seems to be a solution.
|
|
|
|
|
I have an application that loads a specified web page that it have a button i.e with label 'OK'.I need to know how can this button get clicked from my app without user doing this.
MKCoder
|
|
|
|
|
Try looking at firing the event or even just calling the method that would be called by the button click.
Why do you want to simulate a button click?
If you want to simulate a button click then you might need to look at firing a mouse click event.
Hope that gives some direction.
|
|
|
|
|
Pls give me the code to create a mail merge application using Asp.NEt & C#
let the noble thought come from every side-Rig Veda
|
|
|
|
|
2 questions
1.) Why are you trying to create a mail-merge application in .Net when Word and Excel and Outlook will do things like this for you anyway?
2.) Why do you think someone is going to write this for you from scratch?
Try some part of it and when you get stuck ask how to get past that point - there are hundreds and thousands of programmers on here who will be more than happy to help you but only if you help youself to begin with....
Mark.
|
|
|
|
|
Hi There Every Body,
I have a Form that its ctor defined like this :
public FrmOrder(Order order)
{
}
which "Order" is a predefined class.The object "selectedOrder" is an instance of class "Order".
Why Does this call change "selectedOrder" ?
FrmOrder frm = new FrmOrder(selecredOrder);
frm.ShowDialog();
Kind Regards : Ali
|
|
|
|
|
Because an Order is a class, and therefore a reference object. You pass the reference to the object, so there may be many variables all referencing the same physical object. So call a method on one reference that makes a change and everything that has the reference will see the change in the object.
This is different to a value object. In this case a copy of the object is passed, so if a value object is passed into a method then the code inside the method sees a copy of the object, rather than the version that was passed in.
|
|
|
|
|
Thanks Colin,
Whould u please tell me how should I Pass that instance By Value?
And what is the usage of "ref" keyword?
Thanks again.
Yours Sincerely. Ali
|
|
|
|
|
Ali Beirami wrote: how should I Pass that instance By Value?
You can't.
Ali Beirami wrote: And what is the usage of "ref" keyword?
To pass a value type by reference, such as an int.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanx.
Sincerely Yours. Ali
|
|
|
|
|
there is a very subtle use for the ref keyword for objects.
You are saying that you pass the reference by reference.
If you assign an object to a reference you have passed in by val, the reference is not altered when you return from the function. If you pass it in by ref then the reference will be updated on your return
Hope this makes some sense
Russell
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
TestClass newClass = new TestClass("Initial");<br />
Console.WriteLine("Value after initialisation: " + newClass.TestValue);<br />
DoStuffByVal(newClass);<br />
Console.WriteLine("Value after byval: " + newClass.TestValue);<br />
newClass = new TestClass("Initial");<br />
Console.WriteLine("Value after initialisation: " + newClass.TestValue);<br />
DoStuffByRef(ref newClass);<br />
Console.WriteLine("Value after byref: " + newClass.TestValue);<br />
}<br />
private void DoStuffByVal(TestClass testObject)<br />
{<br />
testObject = new TestClass("Changed");<br />
}<br />
private void DoStuffByRef(ref TestClass testObject)<br />
{<br />
testObject = new TestClass("Changed");<br />
}<br />
class TestClass<br />
{<br />
public string TestValue;<br />
public TestClass(string testValue)<br />
{<br />
TestValue = testValue;<br />
}<br />
}
produces the following output
Value after initialisation: Initial
Value after byval: Initial
Value after initialisation: Initial
Value after byref: Changed
|
|
|
|
|
if it's the kind of object that you are likely to need to pass by val you should consider making it a struct instead. I'm thinking of classes like vectors, phone numbers etc which are often better as structs.
Russ
|
|
|
|
|
Hai I had a problem of exporting gridview control(or)dataset to exel sheet.So can u plz provide code with namespaces
|
|
|
|