Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    vbnet


'Catch' Cannot Catch Type 'exception' Because It Is Not 'System.Exception'?

I have a project converted from Visual Studio 2005 to Visual Studio 2010. It compiles and runs.

When I prune "unused references's from this project as listed by Visual Studio, the project fails to compile with the subject error message.

In particular one of the "unused refererences" is to "Microsoft.VisualBasic.dll". The IDE does not allow me to add back this particular reference.

What do I need to add back as a referenceto get this items?

View 4 Replies (Posted: April 16, 2012)

Sponsored Links:

Related Forum Messages For vbnet category:
Error 68 'Catch' Cannot Catch Type 'Microsoft.Office.Interop.Outlook.Exception' Because It Is Not 'System.Exception'
I am using VB.NET 2005 to create a Windows forms application. I have a procedure named SendMail that creates an instance of Outlook.Application, to send an email from my application. I found the code on this forum, I think.The procedure works fine, but I can't use error handling with it.I call the procedure from a button click event. I put the procedure call in a try/catch block, and the application won't build, with the following error.

Error68'Catch' cannot catch type 'Microsoft.Office.Interop.Outlook.Exception' because it is not 'System.Exception' or a class that inherits from 'System.Exception'.C:datadevdmtiQTSQTSv7_1_20100212wQTSQTSReportsCriteria

Here is the code:

Sub SendMail(ByVal sFile As String)
' Create an Outlook application.
Dim oApp As Outlook._Application


Posted: February 12, 2010

View 8 Replies!   View Related
Catch' Cannot Catch Type 'Object' Because It Is Not 'System.Exception' Or A Class That Inherits From 'System.Exception'
I'm getting 'Catch' cannot catch type 'Object' because it is not 'System.Exception' or a class that inherits from 'System.Exception'. and 'Expression detected' Code underlined in blue: Catch obj1 As Object When (?)

Private Sub OpenJAMem()
Dim num3 As Integer


Posted: 10 August 2010

View 2 Replies!   View Related
Error - Catch Cannot Catch Type 'Microsoft.Office.Interop.Outlook.Exception'
I have a program in VB.Net that receives mails from Outlook, extracts attachments and inserts the attachments into a table through a query. I would like to put the query/queries in a Try/Catch block, but cannot do so as Outlook exceptions cannot be caught, and it gives me an error, and unless I put a very specific exception, I cannot catch it. Is there a workaround?


Catch ex As Exception
End Try

Exception is underlined and when I hover on it, it says: "Catch cannot catch type 'Microsoft.Office.Interop.Outlook.Exception' because it is not in 'System.Exception' or a class that inherits from 'System.Exception'". This is affecting all my other code which I'd like to put into a Try/Catch block.

Posted: Mar 25 11 at 6:44

View 2 Replies!   View Related
Nested Try...Catches - If An Exception Occurs In The 2nd Sub's Try...Catch, Which Catch Gets Excecuted?
I have this scenario: in a Sub I have a Try...Catch statement.Within that Try..Catch I call another sub.In that 2nd sub is also a Try...Catch.(see below for example).Now if an exception occurs in the 2nd sub's Try...Catch, which Catch gets excecuted? The 2nd one, the 1st one or both?

Private Sub sub1()
Try stuff[code].....

Posted: Mar 4th, 2009

View 3 Replies!   View Related
If Throw An Exception From Within A Catch, Does The Finally (from The Catch) Still Execute
If I throw an exception from within a catch, does the finally (from the catch) still execute? i.e.

..some code with an exception in it...
catch ex as Exception
throw new SpecialException("blah blah" & ex.Message, ex)


Posted: June 2nd, 2009

View 6 Replies!   View Related
Catch An Exception And Throw A New Exception Which Wraps The First Exception As An Inner Exception
It is possible to catch an exception and throw a new exception which wraps the first exception as an inner exception: [URL] Also, if I call a function and it throws a certain error, but I catch it, will the calling code's catch handler execute? If so, and it is of a higher exception type, is this not wrapping the exception? eg I can throw exception ex of type IndexOutOfRange, log it but rethrow, catch a higher up exception and do something, or I can throw a new exception and wrap an inner exception like:

Posted: May 8 09 at 8:53

View 1 Replies!   View Related
.net - Re-throwing An Exception From An Exception Catch?
catch an exception and then throw another exception? Like so:

' Do operation xxx
Catch ex As Exception
' Operation xxx failed, need to execute cleanup


The reason for doing this is that while I catch my exception on a higher level logic (to make sure I can log it properly), I need to do some actions in the event of the exception that I can only do inside my class/function.

Posted: Feb 14 11 at 20:06

View 3 Replies!   View Related
Catch Inner Exception In NET?
How can I catch an inner exception in .NET? I need to check 2 databases for a record. The database code throws an exception if a record is not found, so then I want to check the second database[code]...

Posted: Oct 13 09 at 4:29

View 5 Replies!   View Related
How To Catch Exception From DLL
I've written a DLL that contains a bunch of classes. One of my methods validates the contents of a file and throws any necessary exceptions based on invalid content - I'm using a standard "throw new exception." call the thing is, when my code reaches the line where the exception is thrown, my Visual Studio IDE hangs up on that line instead of the external call to my validate method.


So my IDE is actually pulling up the VB file that contains the DLL content and highlights the line in the ValidateFile instead of just hanging on the oFC.ValidateFile method line where the exception is thrown instead of the IDE hanging on the oFC.ValidateFile line in my calling application.

I just want user to have access to the any exceptions that are raised. Here if "C:FileThatDoesntExist.txt" file does not exist then Dll throw exception which should be catch through Application.ThreadException.. How to Catch exception from DLL ?

Posted: 09-08-2011

View 3 Replies!   View Related
How To Catch This Exception
System.Data.OleDbException (0x80004005): The changes you requested to the table were not successful because they would create duplicate values in the index, primary key..."I know how to catch all exceptions. But I want to catch THIS SPECIFIC ONE so I can call one of my subroutines to generate a different ID that will not violate the primary key.

Posted: May 01, 2012

View 2 Replies!   View Related
.net - Log With HealthMonitoring An Exception That Was Catch?
I configured HealthMonitoring in my web application to log all exceptions in the database.But, when I gracefully handle some exception by showing a nice message to the user, they are not logged in the database.If I something like Throw ex, the standard error page is be displayed and the error is not gracefully handled.

Is there something else I could add at the end of my error handler to tell the system to also log this error?here an code sample:Dim errorText As String = "Doing Something"Try 'Do Something


Posted: Sep 2 11 at 13:50

View 2 Replies!   View Related
Catch Exception Only In Release?
I have one global generic exception handler(catch ex as Exception) for all unhandled exceptions from application.But in debug mode(app runs from VS) I don`t want that exceptions go to this global handler.Better for me is when VS stops app on place when exception occurs.

Posted: May 28 10 at 23:39

View 2 Replies!   View Related
Using Catch For An Exception That Does Not Occur
What is the code that I can use to describe what happens when there is not just one exception in a'Try...Catch..Finally...End Try' statement? For example: 'Catch' is used to describe what happens when a certain exception occurs, but what can I use to describe what happens when a certain exception does NOT occur?

Posted: March 25, 2012

View 11 Replies!   View Related
Catch / Handle And Then Again Throw Exception?
I ran into an interesting dilemna today. I have a function that handles information and checks for duplicate values, then returns the next number that is not a duplicate. So, I have something like this:

Public Function GetNextNonDuplicateNumber(NumberToCheck as Long) as Long
//the non-duplicate the function will return
Dim NonDuplicate as Long
If CheckForDuplicate(NumberToCheck) = True Then
Throw New DuplicateException()
[Code] .....

As you can see, I want to handle the exception specifically, but I also want to throw it when I'm done because I want to alert other code outside the function. The problem is that simply throwing it exits out of the function with a null value.

Posted: Jun 26 09 at 19:40

View 2 Replies!   View Related
Catch An Exception Generated On Another Thread?
How do you catch an exception generated on another thread

Posted: January 15, 2011

View 12 Replies!   View Related
Catch As Exception Error From Lblfeedback
i must receive that block of an error message from lblfeedback when it happens so i can sort out the problem before the phone rings. i have this block of code


Posted: 11 May 2012

View 2 Replies!   View Related
Exception Handling - Can't Catch COMException
I use the following code to access a VSS item:

Dim sItem As String = "$/MyVssProject/InexistentFile.txt"
Dim oItem As SourceSafeTypeLib.VSSItem = Nothing


The problem I face is when I try to get an instance to a file that doesn't exist in the VSSDB, thus leading to a COMException, which basically wouldn't be of a problem (I would expect). In fact the exception occurs, but instead of proceeding with the catch code, the debug cursor stays on the line "oItem = m_oSourceSafe.VSSItem(sItem)", showing a dialog with title "COMException crossed a native/managed boundary.

From here the execution doesn't proceed, until I change the content of sItem to an existing file.

Why does the exception not get caught, and how can I achieve it?

Environment: VS2010 with .Net 2.0 on WinXP SP3 x86

Posted: Feb 24 at 9:11

View 1 Replies!   View Related
Catch 404 Error Exception On Web Browser Control
How can I catch 404 error on web browser control?

Catch ex As Exception
End Try

Posted: May 28, 2011

View 1 Replies!   View Related
Catch An Exception Thrown By A Control Event?
How can I catch an exception thrown by a control event?I have a control that throws an exception in one of its events and I need to catch it but I don't know how.Consider for example that the text box control throws an exception in its click event. How can I catch such exception?

Posted: January 21, 2011

View 3 Replies!   View Related
Catch An Exception Thrown By JIRA SOAP?
I want to catch the exceptions thrown by the login() function in JIRA's SOAP API. The function login throws 2 exceptions. RemoteAuthenticationException if the user provided an invalid username or password and RemoteException if there was some problem preventing the operation from working. Currently I'm using this code to catch the exception


Posted: Oct 17 11 at 2:44

View 1 Replies!   View Related
Event Causing Error - Cannot Catch Exception
A developer has created a custom control in ASP.NET using VB.NET. The custom control uses a repeater. In certain scenarios, the rpt_ItemDataBound event is encountering a data error. My goal is rather than having the user see the yellow screen of death, give the user a friendlier error explaining exactly what the data error is. I figured I would be able to use a Try/Catch block as shown below throw the exception, however, it appears that the event has nowhere to be thrown to and stops executing at the "End Try" line.

Protected Sub rpt_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rpt1.ItemDataBound, rpt2.ItemDataBound
Catch ex As Exception
Throw ex
End Try
End Sub

In VB.NET, I can find where the repeater's DataSource is being set, however, I can not find a DataBind event. How I can capture the exception in this ASCX control so I can report it to the user. The stack trace looks like this. There is another repeater within the repeater that is actually causing the error (rptOther) and I'm able to catch the error, but I can only throw it to the rpt_ItemDataBound. How rpt_ItemDataBound is getting called without a DataBind event.

at Company.WebForms.Control.rptOther_ItemDataBound(Object sender, RepeaterItemEventArgs e)
at System.Web.UI.WebControls.Repeater.OnItemDataBound(RepeaterItemEventArgs e)
at System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem)
at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource)
at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.Repeater.DataBind()
at Company.WebForms.Control.rpt_ItemDataBound(Object sender, RepeaterItemEventArgs e)

Posted: Apr 22 10 at 21:10

View 1 Replies!   View Related
Exception Handling - Err.Number Versus Try-catch In .net?
I have inherited an old The code mostly uses try-catch for error-handling. However in some places I have found If Err.Number <> 0 Then.If an error occurs, what decides if an Exception should be thrown, or just setting Err?I don't want to handle error both ways...

Posted: Feb 23 11 at 17:03

View 2 Replies!   View Related
Null Reference Exception In Catch Block
I'm trying to catch an invalid entry in a textbox that I use to enter numbers using the subroutine below.

In the Catch blok I want to change the ForeColor of the textbox that contains the invalid entry.

This did function but now gives me a null reference exception on the line where I change the ForeColor.

Private Sub SaveParm()
Dim Temps(2, 2) As Double
Dim Cname As String = "Text0"


Posted: October 18, 2011

View 7 Replies!   View Related
Try/catch Unhandled Exception Has Occurred In Your Application?
In my code I am trying to come up with the following messages using a try/catch Unhandled exception has occurred in your application. If you click continue, the application will ignore this error adn attemp to continue. If you click Quit, the application will close immediately.conversion from string """" to type 'integer' is not valid Warning Icon followed by 3 buttons one that saids the DETAILS, another for CONTINUE, and one for QUIT.Here is part of my code. I did use Try/catch correctly, but it doesnt say the message the way i described it above ..


Posted: 2011

View 6 Replies!   View Related
Unhandled Exception Message Happens Even In A Try/Catch Block?
This is part of my block which handles incoming messages via TCP. Sometimes it sends scrambled messages which are unpredictable and i need a Try + Catch block for it:'


I can either get "Input string not in correct format" or "typecast not valid". But this is simply supposed to be routine to run into and be able to handle. but that stupid error message keeps popping up I've heard of JITDebugging, should I use that?

Posted: Apr 25th, 2011

View 2 Replies!   View Related
.net - Catch CONSTRAINT Exception When Adding Duplicate Unique Id With VB?
I have a problem that adding a new ROW with duplicate UNIQUE id throws CONSTRAINTException that I cannot always catch.. Randomly general exception halts my VB software, sometimes catching works. here is my code.


Posted: Jun 10 09 at 9:33

View 2 Replies!   View Related
Catch Ex As Exception Error - CDate Function Is Null
In the following code an error arises because the date being passed to the cDate function is Null. However, the catch statement is in error and reports index out of range on the Catch Ex as Exception line. The exception helper says the word Exception is in error and advises that it is index out of range.

Posted: June 24, 2011

View 12 Replies!   View Related
Catch Exceptions Without Defining A Local Exception Variable?

Notice the catch (Type) instead of catch (Type myVariable). Is this possible with VB.NET, or do you always have to declare a variable when you catch exception types, like so:


Posted: Apr 6 11 at 18:01

View 1 Replies!   View Related
Generically Implement Exception Logging If I Have Already Got Many Try-catch Block?
I am writing ASP.Net Web-form in VB.

I have a system which have already handled exceptions by try-catch blocks everywhere.How do I quickly and generically implement exception logging like overriding something instead of inserting logging functions in every single catch block?

Posted: Apr 20 at 7:47

View 1 Replies!   View Related
How To Catch Exception On Page While Running Automated Tests
I am doing automation testing of a web application using selenium. While running automation testing of web application you encounter application errors. Is there any way to detect those exceptions. Specially exceptions that are on the page which causes the page to hang up as it is not finding the element it is looking for or page stays on the same page and waitforpage() function keeps running.

Posted: Jul 8 11 at 11:58

View 1 Replies!   View Related
Try / Catch Exception Handling Breaking INSERT Statement
When trying to use Try/Catch in my code the INSERT statement does not work, but when I comment out the Try/Catch it works fine with no error. The section of my code is below:


Posted: September 12, 2010

View 2 Replies!   View Related
Use Do Until With A Previous Try Catch Exception To Avoid Running The Code Twice?
i have this line of code to catch an exception if a letter is inputed, or if it is out of rang as a number, but I have added WHEN to avoid catching numberical data. Now how can I use an exception error to use it before my case statement in order to avoid running the code twice, cause once the case codes has been through it will run a clear txtbox which is already taken care by the try catch, don`t if thats clear for you but i understand it. here is the code in parts...

'Integer Levels: intLvls is egual to the assigned text box, the first one from
'the top, this line of code allow the user input to be captured into a variable.

VS 2008 Remember Textbox Text when Form reopens

Posted: Apr 7 at 2:18

View 1 Replies!   View Related
VS 2008 Catch Exception Write To Log And Then Get Back Into Loop?
How do i catch the exception, write to log and then get back into the loop?[code]i want that app keeps running although an exception is thrown.

Posted: Aug 5th, 2009

View 11 Replies!   View Related
Error - A First Chance Exception Of Type 'System.Exception' Occurred In Microsoft.VisualBasic.dll
I have a large project where we have 2-3 dll projects that are converted from VB6 to VB.NET. We have fixed all the issues that caused compilation errors, and most of obvious issues in running, so now we have basically a program up and running. The exe is created from scratch in VB.NET, using a lot of functionality from the converted dll's (including GUI forms). What I wonder is when I run the program in debug mode, I get a bunch of warnings in the "Immediate Window" saying:

A first chance exception of type 'System.Exception' occurred in Microsoft.VisualBasic.dll

...and some of other type (but most of them in Microsoft.VisualBasic.dll).I was wondering if this is common in projects converted from VB6, or if it is caused by bad design in our code...

Posted: Sep 2 09 at 12:12

View 2 Replies!   View Related
Copyright 2005-08, All rights reserved