Unhandled NullReferenceException when closing FbRemoteEvent -----------------------------------------------------------
Key: DNET-541 URL: http://tracker.firebirdsql.org/browse/DNET-541 Project: .NET Data provider Issue Type: Bug Components: ADO.NET Provider Affects Versions: 4.1.0.0 Environment: WPF application, .Net 4.5 (c#) , Firebird Server 2.5.2.26536 accessed via 127.0.0.1, VS2012 on Win7 x64 Prof. Reporter: G. Krug Assignee: Jiri Cincura Priority: Blocker I have opened an event registration like shown in example at http://www.firebirdsql.org/en/net-examples-of-use/ . CreateConnection creates a new unpooled connection which is only used for this event (beside other connections with Pooling=true) : FbRemoteEventEventHandler handler = new FbRemoteEventEventHandler(this.Update_Event); FbConnection conn = CreateConnection(); FbRemoteEvent rv = new FbRemoteEvent(conn, dbEventNames); rv.RemoteEventCounts += new FbRemoteEventEventHandler(handler); rv.QueueEvents(); private void Update_Event(object sender, FbRemoteEventEventArgs e) { // do something } The registered event(s) are working fine then. If I want to stop event processing with fbEvent.RemoteEventCounts -= handler; // In most cases an unhandled NullReferenceException is thrown, we can not catch it here try { fbEvent.CancelEvents(); } catch (NullReferenceException nre) { // ignore, but log to debug output } if (conn .State != ConnectionState.Closed) { conn .Close(); } conn.Dispose(); // hereafter an unhandled exception is thrown as follows: Exception: System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. bei FirebirdSql.Data.Common.RemoteEvent.EventCounts(Byte[] buffer) in c:\Users\Jiri\Documents\devel\NETProvider\working\NETProvider\source\FirebirdSql\Data\Common\RemoteEvent.cs:Zeile 179. bei FirebirdSql.Data.Client.Managed.Version10.GdsEventManager.<>c__DisplayClassa.<ThreadHandler>b__7(Object param0) in c:\Users\Jiri\Documents\devel\NETProvider\working\NETProvider\source\FirebirdSql\Data\Client\Managed\Version10\GdsEventManager.cs:Zeile 201. bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) When stepping through the code inside my application there is a method in RemoteEvent.cs which is called after cancelling events, closing and disposing connection of that event (see code above): public void EventCounts(byte[] buffer) { int pos = 1; Charset charset = this.db.Charset; .... and this Charset is already null which will lead to the reported exception. As it is thrown asynchronously on the internal worker thread the exception gets not catched by the main thread. Both parts of code are getting called from main thread in an WPF application. This problem is not reproducible with 4.0.0.0 but I had to update to the newest version due to other bugs in there. If there is any way to resolve this immediately, please post here, Thank you in advance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://tracker.firebirdsql.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ Firebird-net-provider mailing list Firebird-net-provider@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/firebird-net-provider