I am using a dataSet in C#. I have done a direct count for the number of items in
the SQL CE database, so I know how many items that I have in the database. There are no deletions in the the database.
I get the following unexplained exception(s) :
A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll
A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll KeyNotFoundException
This manifests where the communication locks with the SQL CE database.
Does anyone know what causes this and how this can be fixed?
I have searched online and am having no luck to any solutions for this :-(
// List to be created
List<TableDat> result = null;
lock (_sqlcn)
{
// Assumes that connection is a valid SqlConnection object.
SqlCeDataAdapter adapter = new SqlCeDataAdapter(orderSQL, _sqlcn);
try
{
// DataSet that will be returned.
System.Data.DataSet ds = new System.Data.DataSet();
int count = adapter.Fill(ds, currentIndex, PageSize, "Logs");
//Iterate through the table and in the List
foreach (System.Data.DataRow myDataRow in ds.Tables["Logs"].Rows)
{
if (result == null)
{
result = new List<TableDat>();
}
result.Add(
new TableDat(
(int)myDataRow[Resources.ID],
(DateTime)myDataRow[Resources.TimeStamp],
(int)myDataRow[Resources.EVENTLOG_SID],
(int)myDataRow[Resources.EVENTLOG_EID])
);
}
// Set the dataSet object to NULL : No longer needed as the list
// has been populated
ds = null;
}
The biggest problem I see is that this stops the SQL CE database working. Soz, I cannot make out what I should do in the exception handling here as I get nothing in my list which means that the caller has no details for the list??
This just manifests itself. I am looking for a solution which can handle the exception and also to know why my database is behaving as such :-(
Stack Trace looks like:
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.IO.IOException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll
A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
KeyNotFoundException
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
Usually you don't really need to worry about first chance exceptions. They are usually anticipated and handled by the lower level code inside the dll.
There's a decent write-up on first chance exceptions here.
You can also disable these messages in Visual Studio. (For VS 2005... not sure on 2008).
Related
I'm testing native app with C# and Appium on Android device.
I'm trying to verify whether an element is visible or not.
the problem is that if the element was not found, the driver quits the test, and I would like to swipe to the end of the page until the object will be found.
the object is at the bottom of the page, for sure.
I used to use ScrollTo method but it was deprecated.
public void SWipeUntilelementVisible()
{
var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5));
bool visible = false;
int counter = 0;
while (visible == false)
{
if (counter > 0)
_driver.Swipe(1200, 1487, 1200, 732, 0);
if (isElementVisible(SendRequirement))
{
visible = true;
Console.WriteLine("Visible");
break;
}
}
}
public bool isElementVisible(IWebElement Elementid)
{
return SendRequirement.Displayed;
}
EDIT
This is the Visual Studio's log printed when it fails to find the object.
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.NotImplementedException' in WebDriver.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
Exception thrown: 'NUnit.Core.NUnitException' in nunit.core.dll
The thread 0x8a8 has exited with code 0 (0x0).
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
The thread 0x27d8 has exited with code 0 (0x0).
The thread 0x1fbc has exited with code 0 (0x0).
The thread 0x16cc has exited with code 0 (0x0).
The thread 0x19d0 has exited with code 0 (0x0).
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.InvalidOperationException' in WebDriver.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
Exception thrown: 'NUnit.Core.NUnitException' in nunit.core.dll
The thread 0x1fd8 has exited with code 0 (0x0).
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
The thread 0x2380 has exited with code 0 (0x0).
The thread 0x19fc has exited with code 0 (0x0).
The thread 0x261c has exited with code 0 (0x0).
The thread 0x256c has exited with code 0 (0x0).
The thread 0x26cc has exited with code 0 (0x0).
The program '[8096] te.processhost.managed.exe' has exited with code 0 (0x0).
seems like the issue resolved. the problem was running on a 64 bit system and trying to load a 32 bit dll.
It doesn't crash, all the exceptions I mention here can only be seen in Output window of Visual Studio. Here is the implementation of Dragging:
WPF:
<StackPanel Orientation="Vertical"
MouseDown="DragShortcut"
x:Name="Shortcut">
<Image Source="{Binding Icon}"/>
<Label Content="{Binding ShortcutLabel}"/>
</StackPanel>
cs code:
private void DragShortcut(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed)
return;
var dataObject = new DataObject(DataFormats.FileDrop, new[] { Options.DragDropOptions.ShortcutPath });
DragDrop.DoDragDrop(Shortcut, dataObject, DragDropEffects.Copy);
}
Everything seems to work as expected, but every time I drag something over my Desktop or Explorer window I receive the following messages in the Output window of my Visual Studio:
...
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.NotImplementedException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
...
When Visual Studio is set to stop on that kind of exceptions, I can see the following Exceptions:
System.Runtime.InteropServices.COMException was unhandled
Message: An exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll and wasn't handled before a managed/native boundary
Additional information: Invalid FORMATETC-Structure (Exception HRESULT: 0x80040064 (DV_E_FORMATETC))
and
System.NotImplementedException was unhandled
Message: An exception of type 'System.NotImplementedException' occurred in PresentationCore.dll and wasn't handled before a managed/native boundary
Additional information: The method or operation is not implemented.
It doesn't lead to crash or anything, it's just uncomfortable for me as a developer to have such a thing happening in background. Does anyone have an Idea what could it be?
EDIT:
This problem looks a lot like mine, but seems to have another cause and solution.
This is entirely normal. Whatever window of another process you drag over will make that process poke the object you drag to see if it supports a particular format or can convert the object to another format. Done with COM calls under the hood. If the answer is "yes" then you see the cursor change to indicate that you can drop.
The IDataObject interface implementation in WPF says "no" by throwing an exception. The normal way in which COM failure codes are generated in a .NET program. That exception gets converted by the CLR into a COM error code, an HRESULT, to tell the process that it isn't going to work. Note how the Exeption class has the HResult property, that's what the process sees.
The debugger dutifully displays the "first chance" exception notification if you asked for it. Right-click the Output window, "Exception Messages" option, turned on by default. Nothing actually goes wrong, the exception is caught and handled gracefully. Feature, not a bug.
I have an ObservableCollection that a ListBox is databound to. I can add items to the ObservableCollection without issue, and the UI updates, but if I try to call either Remove or RemoveAt to allow the user to delete entries I end up with this:
'10Done.WindowsPhone.exe' (CoreCLR: .): Loaded
'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was
built without symbols. A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
mscorlib.ni.dll An exception of type
'System.Runtime.InteropServices.COMException' occurred in
mscorlib.ni.dll but was not handled in user code Additional
information: Error HRESULT E_FAIL has been returned from a call to a
COM component.
Can I not remove items from a collection that is databound?
I have a error in my wpf project. When I want make a new from MainWindow in The following code:
public App()
{
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
if (MyServer.IsAdministrator())
{
if (MyServer.IsRun())
Process.GetCurrentProcess().Kill();
else
{
MainWindow ObjMain = new MainWindow();
ObjMain.Show();
}
}
else
{
new CheckRunAsAdministrator().ShowDialog();
Process.GetCurrentProcess().Kill();
}
}
I see:
An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationCore.dll
Additional information: The calling thread must be STA, because many UI components require this.
But after this error I remove codes in App() and in App.xaml wrote
But I see another problem. Please see the below.
A first chance exception of type 'System.NotImplementedException'
occurred in PresentationFramework.dll
Additional information: The method or operation is not implemented.
and after that:
An unhandled exception of type
'System.Windows.Markup.XamlParseException' occurred in
PresentationFramework.dll
Additional information: The method or operation is not implemented.
what's the problem?
I wrote a code in asp.net that read data from files and draw a graph.
It worked but after awhile when i run the program, this exception arise
"An unhandled exception of type 'System.StackOverflowException'
occurred in mscorlib.dll"
in this statement in the code:
if (File.Exists(fName)) <----(here is the exception)
{
stream = File.Open(fName, FileMode.Open);
g_day = Deserialize(stream);
stream.Close();
int cn = 0;
if (g_day.Values.Count != 0)
cn = g_day.Values[g_day.Values.Count - 1].Value;
Label1.Text = cn.ToString();
}
Your function is probably calling itself recursively an infinite number of times. Sometimes this happens indirectly (you call a method in the BCL and it calls back to your code, and this keeps repeating). File.Exists is probably not the culprit. Look at your call stack when the error occurs.