Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help with exception inside CLR stored proc

1 view
Skip to first unread message

Geoff Chappell

unread,
Jan 13, 2009, 6:35:02 PM1/13/09
to
I'm getting the following exception from within a clr store proc that
executes a query on the context connection. The error occurs on multiple
servers -- I'm not sure of all configurations, but at least one of the boxes
has sql server 2005 sp3.

Anyone have any ideas?

System.NullReferenceException: Object reference not set to an instance of an
object.
System.NullReferenceException:
at System.Data.SqlServer.Internal.CClrXvarProxy.Close()
at System.Data.SqlServer.Internal.StreamOnBlobHandle.Discard()
at System.Data.SqlServer.Internal.XvarBlobStream.Discard()
at System.Data.SqlServer.Internal.SqlBinaryMaxBuffer.Dispose()
at System.Data.SqlServer.Internal.RequestExecutor.Dispose()
at System.Data.SqlServer.Internal.RequestExecutor.Close(SmiEventSink
sink)
at System.Data.SqlClient.SqlCommand.DisposeSmiRequest()
at
System.Data.SqlClient.SqlCommand.SetUpSmiRequest(SqlInternalConnectionSmi
innerConnection)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderSmi(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method,
DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()

Adam Machanic

unread,
Jan 13, 2009, 7:46:07 PM1/13/09
to
Can you show us the code? Have you tried debugging it? A
NullReferenceException can be caused by countless things...

"Geoff Chappell" <GeoffC...@discussions.microsoft.com> wrote in message
news:D386EA15-D5A5-4072...@microsoft.com...

Geoff Chappell

unread,
Jan 14, 2009, 7:50:01 AM1/14/09
to
No, I can't reproduce on my dev machines so I've never caught in a debugger
-- I've only been able to get stack traces dumped and reported back. The
exception is sporadic and seems to happen just once after assemblies are
loaded -- i.e. db restart, new db, etc.

I figured the stack trace was the most relevant info since the null ref is
occurring within msft code. I doubt there's anything I'm doing directly that
is causing it, but am hoping there's some indirect way to control it.

The code is straight forward -- here's the shape of it (though not exact
code):

SqlCommand cmd = new SqlCommand();
cmd.CommandText = @"insert into ...; select ..."
cmd.Parameters.Add(new SqlParameter("@val", SqlDbType.VarBinary, -1))
cmd.Connection = conn; //open context connection that was passed in
cmd.Parameters[0].Value = ...; //param as byte[]
SqlDataReader rdr = cmd.ExecuteReader();

The select query returns a varbinary(8). I've verified through debug dumps
that the params are valid and the same param will work fine through the same
methid in most other cases.

0 new messages