Page 1 of 1

System.InvalidOperationException: Handle is not initialized

Posted: Mon 02 Nov 2009 15:38
by nlundberg
This exception occured when I ran an ASP.NET Application with WebDev.WebServer.exe. It was performing multiple insert statements.

An unhandled exception occurred and the process was terminated.
Application ID: c0fb25be
Process ID: 952
Exception: System.InvalidOperationException
Message: Handle is not initialized.

StackTrace: at System.Runtime.InteropServices.GCHandle.get_Target()
at Devart.Data.Linq.o.i()
at Devart.Data.Linq.d.a(Int32 A_0)
at Devart.Data.Linq.y.a(a A_0)
at Devart.Data.Linq.y.a.b()

Posted: Mon 02 Nov 2009 16:37
by AndreyR
Please specify what dotConnect and of which version you are using.

Posted: Thu 18 Mar 2010 11:17
by dilbert
Today our application was down for a few minutes. In Windows Aplicataion Event Log is this exception. We are using the latest beta version of dotConnect for Mysql (5.70.102.0).
After this error IIS recycled the application.

Code: Select all

An unhandled exception occurred and the process was terminated.
Exception: System.InvalidOperationException

Message: Handle is not initialized.

StackTrace:    at System.Runtime.InteropServices.GCHandle.get_Target()
   at Devart.Data.Linq.c.i()
   at Devart.Data.Linq.g.a(Int32 A_0)
   at Devart.Data.Linq.e.a(a A_0)
   at Devart.Data.Linq.e.a.b()

Posted: Fri 19 Mar 2010 11:49
by AndreyR
The only possible reason we can conclude from our code is multithreading issue.
Please make sure you are using one DataContext object per thread.

Posted: Mon 22 Mar 2010 15:16
by dilbert
I have sent you sample application via email (subject: linq problems) with our typicall using of datacontext.

I would appreciate any suggestion.
Thank you.

Posted: Thu 25 Mar 2010 12:56
by AndreyR
We have replied to your mail.

We are also experiencing this exception

Posted: Wed 21 Jul 2010 23:28
by EricDahlvang
07/20/2010 16:58:55 Unhandled Exception:

Code: Select all

System.InvalidOperationException: Handle is not initialized. 
07/20/2010 16:58:55 	   at System.Runtime.InteropServices.GCHandle.get_Target() 
07/20/2010 16:58:55 	   at Devart.Data.Linq.c.i() 
07/20/2010 16:58:55 	   at Devart.Data.Linq.g.a(Int32 A_0) 
07/20/2010 16:58:55 	   at Devart.Data.Linq.e.a(a A_0) 
07/20/2010 16:58:55 	   at Devart.Data.Linq.e.a.b() 
This exception occurs within the execution path of a single thread. The answer provided by AndreyR is "Make sure you are using one DataContext object per thread" In our current code, we create a data context at the beginning of an operation, and dispose of it when we commit the transaction. We create and destroy multiple data contexts for the duration of the operation. However, we only have one active data context on a thread at any given time, and a thread only ever uses that one data context.

We have spent a significant amount of time attempting to track this down. Any assistance would be greatly appreciated.

Posted: Fri 23 Jul 2010 11:09
by AndreyR
We have not reproduced this error. We have deobfuscated the call stack, the most likely
cause of the problem is the multithreading issue.
That would be great if you are capable of making a small test project reproducing the problem.