cancel
Showing results for 
Search instead for 
Did you mean: 

NullReferenceException in EntityDataRead.Close() when calling a Function Import in EF 4 model

Former Member
3,620

I'm building an application and I have an EF4 EDM. I have imported a number of stored procedures as function imports into the model. Most of these functions do not return any return value.

I'm getting the following null reference exception when I call one of these function import methods:

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Data.EntityClient.EntityDataReader.Close()
   at System.Data.EntityClient.EntityDataReader.Dispose(Boolean disposing)
   at System.Data.Common.DbDataReader.Dispose()
   at System.Data.EntityClient.EntityCommand.ExecuteScalar[T_Result](Func`2 resultSelector)
   at System.Data.EntityClient.EntityCommand.ExecuteNonQuery()
   at System.Data.Objects.ObjectContext.ExecuteFunction(String functionName, ObjectParameter[] parameters)
   at LPRCore.CarSystem.CarSystemEntities.UpsertList(Nullable`1 listId, String listName, Nullable`1 listTypeId, Nullable`1 domainId, String salt, Nullable`1 lastUpdated, Nullable`1 whiteListAlarmClassId, Nullable`1 subscriber, Nullable`1 instanceId) in 😧\\ElsagTFS\\EOC4\\Client\\LPRCore Plugin CarSystem\\CarSystemModel.Designer.cs:line 2050
   at LPRCore.CarSystem.HotListDataAccessor.SaveHotList(CarSystemEntities context, Nullable`1 subscriberId, Nullable`1 instanceId, HotList data) in 😧\\ElsagTFS\\EOC4\\Client\\LPRCore Plugin CarSystem\\HotListDataAccessor.cs:line 268

How do I correct this, or is it a problem in the provider?

Tony

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

I've found that the null reference exception does not occur if I modify the stored procedure so it returns a value by adding "SELECT 1;" to the end of the stored procedure. This is even though the Function Import's properties indicate that the return type is None.

We are actually in the process of evaluating SA and I have a contact inside Sybase. I've also reported this to him. He's been able to reproduce the issue and has sent it to the internal team responsible for this. So it is probably going to be fixed and released soon.

Answers (1)

Answers (1)

Former Member

This issue has been tracked and fixed under CR 718762.

This fix will be in 12.0.1.3790, 11.0.1.2871, and future EBFs.

Former Member
0 Kudos

Tyson: Thanks! When will this EBF be released?

reimer_pods
Participant

If you're on MacOS, build 3798 should contain that fix. Otherwise wait and see ... 😉