I am working on a mobile application that will run on a Symbol barcoding device.
I have a form that captures a barcode, sends it to the business layer that queries a database for existence.
if the barcode can not be found it opens a new form that allows the users to enter data. This form also queries
the database to populate combo boxes. Once the from has been submitted the form is closed and processing
resumes in the business layer. If a flag has been set the method is called again to re-run the database check to
find the newly added item and then populates a list box. The scanning process then begins again.
The application will allow you to add 2 items following this path with no problems. On the third attempts users are
able to enter data and submit the form, however the application then hangs. The data is written to the database and
stepping through the code I can see that control is passed back to the business layer but then hangs.
I have selected the ‘Break All’ option under the debug menu and it seems the problem has to do with Garbage Collection.
Bellow is a copy of the “Call Stack” once the ‘Break All’ has been selected.
>(yellow arrow) mscorlib.dll!System.PInvoke.EE.GC_WaitForPendingFinalizers()
mscorlib.dll!System.GC.WaitForPendingFinalizers() + 0x5 bytes
System.Data.SqlServerCe.dll!System.Data.SqlServerCe.SqlCeConnection.ObjectLifeTimeTracker.Close() + 0x169 bytes
System.Data.SqlServerCe.dll!System.Data.SqlServerCe.SqlCeConnection.Close(bool silent = false) + 0x27 bytes
System.Data.SqlServerCe.dll!System.Data.SqlServerCe.SqlCeConnection.Close() + 0x7 bytes
>(green arrow) EMITSDevice.exe!EMITSDevice.Lib.EMITSData.GetPersonnelByCode(string code = "newbarcode") Line 239 + 0x6 bytes C#
EMITSDevice.exe!EMITSDevice.NewBarcode.AssetSave_Click(object sender = {Text = Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}, System.EventArgs e = {System.EventArgs}) Line 216 + 0x16 bytes C#
System.Windows.Forms.dll!System.Windows.Forms.Control.OnClick(System.EventArgs e = {System.EventArgs}) + 0x15 bytes
System.Windows.Forms.dll!System.Windows.Forms.Button.OnClick(System.EventArgs e = {System.EventArgs}) + 0x32 bytes
System.Windows.Forms.dll!System.Windows.Forms.ButtonBase.WnProc(Microsoft.AGL.Forms.WM wm = WM_BUTTON_NOTIFYCLICKED, int wParam = 0, int lParam = 0) + 0x17 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control._InternalWnProc(Microsoft.AGL.Forms.WM wm = WM_BUTTON_NOTIFYCLICKED, int wParam = 0, int lParam = 0) + 0x9 bytes
System.Windows.Forms.dll!Microsoft.AGL.Forms.EVL.EnterModalDialog(System.IntPtr hwnModal = 2293761)
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog() + 0x53 bytes
EMITSDevice.exe!EMITSDevice.Lib.EMITSBusiness.CheckAssets(string code = "T000088") Line 758 + 0x7 bytes C#
EMITSDevice.exe!EMITSDevice.ScanItem.HandleData(Symbol.Barcode.ReaderData TheReaderData = {Symbol.Barcode.ReaderData}) Line 188 + 0x11 bytes C#
EMITSDevice.exe!EMITSDevice.ScanItem.AssetReader_ReadNotify(object sender = {Symbol.Barcode.Reader}, System.EventArgs e = {System.EventArgs}) Line 157 + 0x7 bytes C#
Symbol.Barcode.dll!Symbol.Barcode.Reader.OnReadNotify(System.EventArgs e = {System.EventArgs}) + 0x15 bytes
Symbol.dll!Symbol.Marshaller.SymbolMessageWindow.WndProc(ref Microsoft.WindowsCE.Forms.Message msg = {Microsoft.WindowsCE.Forms.Message}) + 0x40 bytes
Microsoft.WindowsCE.Forms.dll!Microsoft.WindowsCE.Forms.MessageWindow._WndProc(ref Microsoft.WindowsCE.Forms.Message msg = {Microsoft.WindowsCE.Forms.Message}) + 0x7 bytes
System.Windows.Forms.dll!Microsoft.AGL.Forms.EVL.EnterMainLoop(System.IntPtr hwnMain = 3211277)
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form fm = {EMITSDevice.mainEMITS}) + 0x1a bytes
EMITSDevice.exe!EMITSDevice.Program.Main() Line 20 + 0xa bytes C#

mobil app hanging on mscorlib.dll!System.PInvoke.EE.GC_WaitForPendingFinalizers() (I think)
daimaku
Probably one of finalizers hangs and WaitForPendingFinalizers() never exits. That finalizer might be in your code, NETCF’s code or 3rd party code (e.g. scanner SDK).
It’s not the first time I see similar issues with Symbol scanning SDK, so I would guess the issues is in this SDK. You should check your code just in case if you have finalizers.
sniwas24x7
Thanks for your prompt reply.
I have gone back through the code and there is no call to Dispose(), all SqlCE connections are being Closed().
I do have a “using” statement that opens the data entry form using the ShowDialog(), so that would call the Dispose() method once that form has closed.
Do you have any other suggestions as how best to open a pop up window for data entry then continue on with the execution path once the form has closed
I did read another post regarding Symbols SDK and problems with GC. Symbol seemed to blame the Compact Framework and not their SDK.
However, I have contacted Symbol to help troubleshoot this issue.
Marauderz
daniel.ef
okay, I have removed the referrence to the Symbol SMDK within the projects and i still get the applicaiton to hang.
it seemes to hange when the code executes the selectCommand.ExecuteReader(CommandBehavior.CloseConnection);
Has anyone reported problems with the SQL Mobile assemblies. I am at the end of the rope with trying to figure this error out. Also, when the code errors there is no exception message.
SqlCeConnection
sqlConn = null; try{
sqlConn =
new SqlCeConnection(Con); //Create a SqlCeCommand object on your connection SqlCeCommand selectCommand = sqlConn.CreateCommand(); //Set the CommandText for the command //The 's represent parameters that will be set later.selectCommand.CommandText =
"SELECT Inventory.Inventory_ID, Inventory.TagID, Inventory.Description, " + "Inventory.Personnel_ID , Inventory.Personnel2_ID,InventoryType.InventoryTypeName " + "FROM Inventory INNER JOIN InventoryType ON " + "Inventory.InventoryType_ID = InventoryType.InventoryType_ID and " + "Inventory.Inventory_ID = "; //Add parameters and assign them the values from the textboxes on the formselectCommand.Parameters.Add(
new SqlCeParameter("Inventory_ID", SqlDbType.UniqueIdentifier, 16));selectCommand.Parameters[
"Inventory_ID"].Value = id;sqlConn.Open();
// 3rd time it errors at this point with no exception details.r = selectCommand.ExecuteReader(
CommandBehavior.CloseConnection);}
catch (SqlCeException e){
//Add error handling code here throw e;}
SanK
It really has nothing to do with Dispose() or SQL Mobile or using statements. The problem might be what some class has finalizer which hangs. There were no reports of that in SQL Mobile or NETCF itself which makes Symbol SDK most likely suspect. You can run reflector on Symbol SDK (see EULA if you can) to see if they are indeed using finalizes. Here’s a sample of obviously bad code, you should be able to reproduce the problem by creating instance of this class (don’t keep reference to it) and calling GC.Collect() and GC.WaitForPendingFinalizers().
public class BadFinalizer
{
public BadFinalizer()
{
System.Diagnostics.Debug.WriteLine("BadFinalizer instance created");
}
~BadFinalizer()
{
while(true)
{
System.Diagnostics.Debug.WriteLine("BadFinalizer finalizing...");
System.Threading.Thread.Sleep(1000);
}
}
}