Bug 31914 - EntityFramework - NullReferenceException
Summary: EntityFramework - NullReferenceException
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 4.0.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
: 48110 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-07-14 07:22 UTC by matanya
Modified: 2017-09-01 09:30 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample project to reproduce the error (10.88 KB, application/gzipped-tar)
2015-07-14 07:22 UTC, matanya
Details

Description matanya 2015-07-14 07:22:24 UTC
Created attachment 12011 [details]
Sample project to reproduce the error

Attached is a sample code that shows a bug in entity framework, probably very similar to https://bugzilla.xamarin.com/show_bug.cgi?id=10271

here is the stack trace:

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Xml.XmlInputStream.Initialize (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at System.Xml.XmlInputStream..ctor (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Xml.XmlInputStream:.ctor (System.IO.Stream)
  at System.Xml.XmlStreamReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Xml.XmlStreamReader:.ctor (System.IO.Stream)
  at System.Xml.XmlTextReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0 
  at System.Xml.Schema.XmlSchema.Read (System.IO.Stream stream, System.Xml.Schema.ValidationEventHandler validationEventHandler) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema+SomSchemaSetHelper.AddXmlSchemaToSet (System.Xml.Schema.XmlSchemaSet schemaSet, XmlSchemaResource schemaResource, System.Collections.Generic.HashSet`1 schemasAlreadyAdded) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema+SomSchemaSetHelper.AddXmlSchemaToSet (System.Xml.Schema.XmlSchemaSet schemaSet, XmlSchemaResource schemaResource, System.Collections.Generic.HashSet`1 schemasAlreadyAdded) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema+SomSchemaSetHelper.ComputeSchemaSet (SchemaDataModelOption dataModel) [0x00000] in <filename unknown>:0 
  at System.Data.Common.Utils.Memoizer`2+<Evaluate>c__AnonStorey0[System.Data.EntityModel.SchemaObjectModel.SchemaDataModelOption,System.Xml.Schema.XmlSchemaSet].<>m__0 () [0x00000] in <filename unknown>:0 
  at System.Data.Common.Utils.Memoizer`2+Result[System.Data.EntityModel.SchemaObjectModel.SchemaDataModelOption,System.Xml.Schema.XmlSchemaSet].GetValue () [0x00000] in <filename unknown>:0 
  at System.Data.Common.Utils.Memoizer`2[System.Data.EntityModel.SchemaObjectModel.SchemaDataModelOption,System.Xml.Schema.XmlSchemaSet].Evaluate (SchemaDataModelOption arg) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema+SomSchemaSetHelper.GetSchemaSet (SchemaDataModelOption dataModel) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema.CreateXmlReaderSettings () [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema.Parse (System.Xml.XmlReader sourceReader, System.String sourceLocation) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.SchemaManager.ParseAndValidate (IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, System.Data.EntityModel.SchemaObjectModel.AttributeValueNotification providerNotification, System.Data.EntityModel.SchemaObjectModel.AttributeValueNotification providerManifestTokenNotification, System.Data.EntityModel.SchemaObjectModel.ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.SchemaManager.ParseAndValidate (IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, System.Data.Common.DbProviderManifest providerManifest, IList`1& schemaCollection) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.EdmItemCollection.LoadItems (IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModelOption, System.Data.Common.DbProviderManifest providerManifest, System.Data.Metadata.Edm.ItemCollection itemCollection, Boolean throwOnError) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.EdmItemCollection.Init (IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.EdmItemCollection..ctor (IEnumerable`1 xmlReaders, IEnumerable`1 filePaths) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.MetadataCache+EdmMetadataEntry.LoadEdmItemCollection (System.Data.Metadata.Edm.MetadataArtifactLoader loader) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.MetadataCache+EdmItemCollectionLoader.LoadItemCollection (System.Data.Metadata.Edm.EdmMetadataEntry entry) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.MetadataCache.LoadItemCollection[EdmMetadataEntry] (IItemCollectionLoader`1 itemCollectionLoader, System.Data.Metadata.Edm.EdmMetadataEntry entry) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.MetadataCache.GetOrCreateEdmItemCollection (System.String cacheKey, System.Data.Metadata.Edm.MetadataArtifactLoader loader, System.Object& entryToken) [0x00000] in <filename unknown>:0 
  at System.Data.EntityClient.EntityConnection.LoadEdmItemCollection (System.Data.Metadata.Edm.MetadataWorkspace workspace, System.Data.Metadata.Edm.MetadataArtifactLoader artifactLoader) [0x00000] in <filename unknown>:0 
  at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace (Boolean initializeAllCollections) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Data.EntityClient.EntityConnection:GetMetadataWorkspace (bool)
  at System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection () [0x00000] in <filename unknown>:0 
  at System.Data.Objects.ObjectContext..ctor (System.Data.EntityClient.EntityConnection connection, Boolean isConnectionConstructor) [0x00000] in <filename unknown>:0 
  at System.Data.Objects.ObjectContext..ctor (System.Data.EntityClient.EntityConnection connection) [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.LazyInternalContext.InitializeContext () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.InternalContext.Initialize () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext () [0x00000] in <filename unknown>:0 
  at SqlServerConsoleApp.FluentControllerUniTestEntities.aspAlgoCurrencyPairGet () [0x00000] in <filename unknown>:0 
  at SqlServerConsoleApp.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Xml.XmlInputStream.Initialize (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at System.Xml.XmlInputStream..ctor (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Xml.XmlInputStream:.ctor (System.IO.Stream)
  at System.Xml.XmlStreamReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Xml.XmlStreamReader:.ctor (System.IO.Stream)
  at System.Xml.XmlTextReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0 
  at System.Xml.Schema.XmlSchema.Read (System.IO.Stream stream, System.Xml.Schema.ValidationEventHandler validationEventHandler) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema+SomSchemaSetHelper.AddXmlSchemaToSet (System.Xml.Schema.XmlSchemaSet schemaSet, XmlSchemaResource schemaResource, System.Collections.Generic.HashSet`1 schemasAlreadyAdded) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema+SomSchemaSetHelper.AddXmlSchemaToSet (System.Xml.Schema.XmlSchemaSet schemaSet, XmlSchemaResource schemaResource, System.Collections.Generic.HashSet`1 schemasAlreadyAdded) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema+SomSchemaSetHelper.ComputeSchemaSet (SchemaDataModelOption dataModel) [0x00000] in <filename unknown>:0 
  at System.Data.Common.Utils.Memoizer`2+<Evaluate>c__AnonStorey0[System.Data.EntityModel.SchemaObjectModel.SchemaDataModelOption,System.Xml.Schema.XmlSchemaSet].<>m__0 () [0x00000] in <filename unknown>:0 
  at System.Data.Common.Utils.Memoizer`2+Result[System.Data.EntityModel.SchemaObjectModel.SchemaDataModelOption,System.Xml.Schema.XmlSchemaSet].GetValue () [0x00000] in <filename unknown>:0 
  at System.Data.Common.Utils.Memoizer`2[System.Data.EntityModel.SchemaObjectModel.SchemaDataModelOption,System.Xml.Schema.XmlSchemaSet].Evaluate (SchemaDataModelOption arg) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema+SomSchemaSetHelper.GetSchemaSet (SchemaDataModelOption dataModel) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema.CreateXmlReaderSettings () [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.Schema.Parse (System.Xml.XmlReader sourceReader, System.String sourceLocation) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.SchemaManager.ParseAndValidate (IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, System.Data.EntityModel.SchemaObjectModel.AttributeValueNotification providerNotification, System.Data.EntityModel.SchemaObjectModel.AttributeValueNotification providerManifestTokenNotification, System.Data.EntityModel.SchemaObjectModel.ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection) [0x00000] in <filename unknown>:0 
  at System.Data.EntityModel.SchemaObjectModel.SchemaManager.ParseAndValidate (IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, System.Data.Common.DbProviderManifest providerManifest, IList`1& schemaCollection) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.EdmItemCollection.LoadItems (IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModelOption, System.Data.Common.DbProviderManifest providerManifest, System.Data.Metadata.Edm.ItemCollection itemCollection, Boolean throwOnError) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.EdmItemCollection.Init (IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.EdmItemCollection..ctor (IEnumerable`1 xmlReaders, IEnumerable`1 filePaths) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.MetadataCache+EdmMetadataEntry.LoadEdmItemCollection (System.Data.Metadata.Edm.MetadataArtifactLoader loader) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.MetadataCache+EdmItemCollectionLoader.LoadItemCollection (System.Data.Metadata.Edm.EdmMetadataEntry entry) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.MetadataCache.LoadItemCollection[EdmMetadataEntry] (IItemCollectionLoader`1 itemCollectionLoader, System.Data.Metadata.Edm.EdmMetadataEntry entry) [0x00000] in <filename unknown>:0 
  at System.Data.Metadata.Edm.MetadataCache.GetOrCreateEdmItemCollection (System.String cacheKey, System.Data.Metadata.Edm.MetadataArtifactLoader loader, System.Object& entryToken) [0x00000] in <filename unknown>:0 
  at System.Data.EntityClient.EntityConnection.LoadEdmItemCollection (System.Data.Metadata.Edm.MetadataWorkspace workspace, System.Data.Metadata.Edm.MetadataArtifactLoader artifactLoader) [0x00000] in <filename unknown>:0 
  at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace (Boolean initializeAllCollections) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Data.EntityClient.EntityConnection:GetMetadataWorkspace (bool)
  at System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection () [0x00000] in <filename unknown>:0 
  at System.Data.Objects.ObjectContext..ctor (System.Data.EntityClient.EntityConnection connection, Boolean isConnectionConstructor) [0x00000] in <filename unknown>:0 
  at System.Data.Objects.ObjectContext..ctor (System.Data.EntityClient.EntityConnection connection) [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.LazyInternalContext.InitializeContext () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.InternalContext.Initialize () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes () [0x00000] in <filename unknown>:0 
  at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext () [0x00000] in <filename unknown>:0 
  at SqlServerConsoleApp.FluentControllerUniTestEntities.aspAlgoCurrencyPairGet () [0x00000] in <filename unknown>:0 
  at SqlServerConsoleApp.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 matanya 2015-07-14 07:50:24 UTC
Some additional info: Those only happens in EntityFramework: 5, switching to 6 solves this issue.
.Net version is 4.5
Comment 2 bruno.tete 2016-11-28 11:24:46 UTC
*** Bug 48110 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.