In this case, what's the difference between CSharp and VB.NET Exception Handling 
Author Message
 In this case, what's the difference between CSharp and VB.NET Exception Handling

Okay, I know I must be missing something simple here, so if someone could
knock me on the head that would be great. I have two console applications
here, one written in C#, and the other in VB.NET:

using System;

namespace csharpConsole
{
 class Class1
 {
  [STAThread]
  static void Main(string[] args)
  {
   //throw C# exception
   throw new myCSharpException.myCSharpException();
   //throw Vb exception
   throw new myVBException.myVBException();
  }
 }

Quote:
}

Module Module1

    Sub Main()
        'throw VB exception
        Throw New myVBException.myVBException
        'throw C# exception
        Throw New myCSharpException.myCSharpException
    End Sub

End Module

As you can tell, each one throws an exception. The exception class is
defined in another project, and so I include the DLL for that class library
in the C# and VB projects respectively. One of the exceptions is written in
C#, and the other is in VB.NET:

using System;

namespace myCSharpException
{
 public class myCSharpException:System.ApplicationException
 {
  public myCSharpException()
  {
   Console.WriteLine("Hello from C# Exception");
  }
 }

Quote:
}

Public Class myVBException
    Inherits System.ApplicationException
    Public Sub myVBException()
        Console.WriteLine("Hello from VB Exception")
    End Sub
End Class

I comment out the exception I don't choose to execute in the console app and
then run.

The strangeness happens when I run the two different console applications,
though. I always get "Hello from C# Exception" to appear on either console,
but I NEVER get the "Hello from VB Exception" to appear on either console.
The reason I did this from the very beginning is because I have some code
executing in the constructor of my VB.NET exception (in a real world
application) that doesn't appear to be executing. I made this simple test
and, voila, I get the same results - the Console.WriteLine() doesn't appear
to execute.

Any ideas? I know C# pretty well, but I'm just learning VB.NET so there may
be a stupid little error in that.....(not to say I'm not messing up anything
in C#)

Ben



Sat, 27 Aug 2005 14:23:12 GMT  
 In this case, what's the difference between CSharp and VB.NET Exception Handling
Don't you hate misreading something and then paying the price? VB.NET uses
New for constructors and not the name like C#. *grumble*


Quote:
> Okay, I know I must be missing something simple here, so if someone could
> knock me on the head that would be great. I have two console applications
> here, one written in C#, and the other in VB.NET:

> using System;

> namespace csharpConsole
> {
>  class Class1
>  {
>   [STAThread]
>   static void Main(string[] args)
>   {
>    //throw C# exception
>    throw new myCSharpException.myCSharpException();
>    //throw Vb exception
>    throw new myVBException.myVBException();
>   }
>  }
> }

> Module Module1

>     Sub Main()
>         'throw VB exception
>         Throw New myVBException.myVBException
>         'throw C# exception
>         Throw New myCSharpException.myCSharpException
>     End Sub

> End Module

> As you can tell, each one throws an exception. The exception class is
> defined in another project, and so I include the DLL for that class
library
> in the C# and VB projects respectively. One of the exceptions is written
in
> C#, and the other is in VB.NET:

> using System;

> namespace myCSharpException
> {
>  public class myCSharpException:System.ApplicationException
>  {
>   public myCSharpException()
>   {
>    Console.WriteLine("Hello from C# Exception");
>   }
>  }
> }

> Public Class myVBException
>     Inherits System.ApplicationException
>     Public Sub myVBException()
>         Console.WriteLine("Hello from VB Exception")
>     End Sub
> End Class

> I comment out the exception I don't choose to execute in the console app
and
> then run.

> The strangeness happens when I run the two different console applications,
> though. I always get "Hello from C# Exception" to appear on either
console,
> but I NEVER get the "Hello from VB Exception" to appear on either console.
> The reason I did this from the very beginning is because I have some code
> executing in the constructor of my VB.NET exception (in a real world
> application) that doesn't appear to be executing. I made this simple test
> and, voila, I get the same results - the Console.WriteLine() doesn't
appear
> to execute.

> Any ideas? I know C# pretty well, but I'm just learning VB.NET so there
may
> be a stupid little error in that.....(not to say I'm not messing up
anything
> in C#)

> Ben



Sat, 27 Aug 2005 14:36:23 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Which has more jobs - CSharp or VB.NET?

2. Difference between VB NET and VB NET 2003

3. VB.net and ASP.net what is the difference

4. Differences between VB.NET and VSPro.NET?

5. Remaining differences VB.NET <> C++.NET

6. ActiveX Component Can't Create Object Exception in ASP.Net

7. How to get Word document's CustomDocumentProperties in CSHARP

8. First hands-on w VB.Net

9. Difference between VB 6 & Vb.Net

10. differences to VB 6 for VB.NET

11. differences to VB 6 for VB.NET

12. 'net use \\servername' in VB.NET

 

 
Powered by phpBB® Forum Software