Surely this shouldn't be happening! The following code creates a connection, DataAdapter & DataSet, then fills the DataSet. the myDataAdapter.Fill creates a 'first chance exception', whatever that is
Imports System.Data.SqlServerCe
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConn As New SqlCeConnection("Data Source = \my documents\MASDB.sdf")
myConn.Open()
Dim myDataAdapter As SqlCeDataAdapter = New SqlCeDataAdapter("Select * FROM AppSettings", myConn)
Dim myData As System.Data.DataSet = New System.Data.DataSet
myDataAdapter.Fill(myData)
End Sub
End Class
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
I seem to get a few first chance exceptions, but ignore them, as
a) I have no idea what they are, neither does MSDN
b) I have no idea how to fix it
However, it does seem to cause a problem later in my code, so I want rid of it, any ideas

first chance exception of type 'System.IO.IOException'
xian_ve
The reason you see this message in debugger is a handled exception is internal procedure which retrieves exception message for exception which occurred previously. < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Your real problem is this first exception, not the handled exception. You should catch this exception and print out error message and/or errors from error collection.
Bob Clemens
Sure. Somewhere deep in resource processing code we have something like this:
try {
// Try loading some strings here.
} catch {
// Oops, could not load strings, try another way.
}
Exception is thrown and handled already, it would never show up in your application. The only way to see it is to attach debugger and observe this message.
As you could see from the code, it has nothing to do with your problem. The real problem here is what debugger shows you something you should not see. I’ll file a bug to mask it out in next version so nobody else would be confused and distracted from the real problem.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
savior1980
Yes, there's a number of cases when framework would throw and handle exceptions. We’re working on reducing number of such cases for performance reasons. Otherwise this is normal and has no impact on your application.
Yiling Lai
You probably getting another exception which is up to you to process. Handled exception happens on attempt to retrieve exception message for original exception. You should ignore handled exception, but you have to process the first one.
Charlie Bis
mr_trixter
Gabriel Kevorkian
crimson33
Hi Ilya,
There seems to be a lot of first time exceptions with the compact framework, that slow things down somewhat. I've experimented a little and it appears to be to do with the use of the My.Resources namespace to reference resource strings. It also occurs when using a sqlce data adapter or reader.
e.g. when directly calling on a resource with the My.Resources namespace:
* A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
* A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
or when initialising a form, the CF generates these exceptions:
* A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
* A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
or when using a datareader to read a SQLCE 3.0 table
* A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
Also, every time a web service is used with a valid "http://..." URL, the CF generates the exception:
* A first chance exception of type 'System.UriFormatException' occurred in System.dll
Are some of these problems to do with a setting I've overlooked, e.g. security, or unresolved bugs in the CF
Rom90125
NB I've discovered that:
* A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
* A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
* A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
was caused by using the Icon property of a form to store an icon - the resource manager doesn't seem to like it!
Esemi
Thanks. Wasn't sure if I was missing something.
NB Worked around the issue of using the My.Resources namespace by making my own global variable for the resource manager (at least until all forms are instantiated), that way the errors only occur the first time it's referenced for a string, instead of every time a new form references the My.Resources namespace. Also, icons loaded into memory variables once has reduced the impact of lengthy first chance 'access denied' exceptions, every time icons are pulled from a resource file.
.... Thought this would be useful info!
Kaetemi
Yes, it's a good idea to cache resource data instead of retrieving it every time. Even though these exception are not "errors" per se as they are expected and handled, they do have performance impact.
Daniel Reis
I created a 2nd test application using .netcf 1.0 and System.Data.SqlServerCe v1.0.5000.0, runtime v1.1.4322, and got no problem
Is there I way I can handle this exception so that it doesn't cause this problem
Ilya, I didn't really understand your previous post, could you please elaborate
I've spent 5 days trying to work this out now, am I banging my head against a brick wall My boss isn't too happy either!
Is there a reason why System.Data.SqlServerCe has this *new* bug in it
aydin1
Ich bin UE.
I want ignore it . But my application always exit unknown. I must fix the "first chance exception of type'system.IO.IOException' "
please help me, Ilya Tumanov.Thank you.