You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
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.
The text was updated successfully, but these errors were encountered:
I have found a workaround to get events working without exceptions or missing event notifications.
Therefore I have to use a separate connection *without* pooling and do *not* close this connection at all. Even when the program is closing the connection must stay open (do not call Close() at any time) as long as it can and is possibly getting disposed at last.
Otherwise it seems the connection is returned to the pool after establishing the event connection but can't be used for other statements to execute as there are many exceptions (bad transaction state, broken blob field pointer, null-refs, etc.) thrown then.
This behaviour is reported in some other developer blogs and (russian) documentation I have finally found. There is no place one can find this information in one place I think.
Submitted by: G. Krug (krugg)
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):
....
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.
The text was updated successfully, but these errors were encountered: