{"id":1949,"date":"2022-08-30T15:20:47","date_gmt":"2022-08-30T15:20:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/05\/mysql-connector-always-get-object-reference-not-set-to-an-instance-of-an-object-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:47","modified_gmt":"2022-08-30T15:20:47","slug":"mysql-connector-always-get-object-reference-not-set-to-an-instance-of-an-object-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/mysql-connector-always-get-object-reference-not-set-to-an-instance-of-an-object-collection-of-common-programming-errors\/","title":{"rendered":"Mysql Connector always get Object reference not set to an instance of an object-Collection of common programming errors"},"content":{"rendered":"<p>My whole app is simply connect to mysql database and insert data using Entityframework. the code works well locally but when i upload in my amazon server, it just give me this error: you can see at http:\/\/fb1.131x.com\/test_data.aspx<\/p>\n<p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Details: System.NullReferenceException: Object reference not set to an instance of an object.<\/p>\n<pre><code>Source Error: \n\nAn unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.\n\nStack Trace: \n\n\n[NullReferenceException: Object reference not set to an instance of an object.]\n   MySql.Data.MySqlClient.MySqlClientFactory.get_MySqlDbProviderServicesInstance() +126\n   MySql.Data.MySqlClient.MySqlClientFactory.System.IServiceProvider.GetService(Type serviceType) +39\n   System.Data.Common.DbProviderServices.GetProviderServices(DbProviderFactory factory) +89\n   System.Data.Metadata.Edm.Loader.InitializeProviderManifest(Action`3 addError) +174\n   System.Data.EntityModel.SchemaObjectModel.Schema.HandleAttribute(XmlReader reader) +301\n   System.Data.EntityModel.SchemaObjectModel.SchemaElement.ParseAttribute(XmlReader reader) +121\n   System.Data.EntityModel.SchemaObjectModel.SchemaElement.Parse(XmlReader reader) +106\n   System.Data.EntityModel.SchemaObjectModel.Schema.HandleTopLevelSchemaElement(XmlReader reader) +49\n   System.Data.EntityModel.SchemaObjectModel.Schema.InternalParse(XmlReader sourceReader, String sourceLocation) +984\n   System.Data.EntityModel.SchemaObjectModel.Schema.Parse(XmlReader sourceReader, String sourceLocation) +245\n   System.Data.EntityModel.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1&amp; schemaCollection) +472\n   System.Data.Metadata.Edm.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths) +162\n   System.Data.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, DbProviderManifest&amp; providerManifest, DbProviderFactory&amp; providerFactory, String&amp; providerManifestToken, Memoizer`2&amp; cachedCTypeFunction) +203\n   System.Data.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths) +305\n   System.Data.Metadata.Edm.StoreMetadataEntry.LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader) +129\n   System.Data.Metadata.Edm.MetadataCache.LoadItemCollection(IItemCollectionLoader`1 itemCollectionLoader, T entry) +165\n   System.Data.Metadata.Edm.MetadataCache.GetOrCreateStoreAndMappingItemCollections(String cacheKey, MetadataArtifactLoader loader, EdmItemCollection edmItemCollection, Object&amp; entryToken) +245\n   System.Data.EntityClient.EntityConnection.LoadStoreItemCollections(MetadataWorkspace workspace, DbConnection storeConnection, DbProviderFactory factory, DbConnectionOptions connectionOptions, EdmItemCollection edmItemCollection, MetadataArtifactLoader artifactLoader) +312\n   System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections) +802\n   System.Data.EntityClient.EntityConnection.InitializeMetadata(DbConnection newConnection, DbConnection originalConnection, Boolean closeOriginalConnectionOnFailure) +11108961\n   System.Data.EntityClient.EntityConnection.Open() +198\n   System.Data.Objects.ObjectContext.EnsureConnection() +97\n   System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) +651\n   System.Data.Entity.Internal.InternalContext.SaveChanges() +218\n   test_data.Page_Load(Object sender, EventArgs e) +231\n   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25\n   System.Web.UI.Control.LoadRecursive() +71\n   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064\nException\n<\/code><\/pre>\n<p>And I also paste my webconfig, i try to use 6.3.5 and 6.4.4 version, i just get same error.<\/p>\n<pre><code>\n\n\n    \n        \n        \n    \n    \n        \n        \n            \n                \n                \n                \n            \n            \n                \n            \n        \n    \n    \n        \n            \n            \n        \n    \n    \n        \n            \n                \n            \n        \n    \n    \n        \n    \n\n<\/code><\/pre>\n<ol>\n<li>\n<p>It seems that you did not include the reference for MySql.Data.Entity. Without that dll it wont work<\/p>\n<\/li>\n<li>\n<p>These are some of the things u could try. it is always a difficult step to deploy an application on a hosting provider. once it gets going it does get going though.<\/p>\n<ul>\n<li>a.build clean.<\/li>\n<li>b.build mysql dll into ur bin directory<\/li>\n<li>c.Install nuget packages for MySQL.Data and MySQL.Data.Entities.((right click on assembly and ensure Copy Local is set to true before building)<\/li>\n<li>d.Remove Version=6.3.5.0 tag entirely and build without any versioning on VS.type=&#8221;MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data&#8221; instead of specifying the full version data.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-05 16:29:54. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>My whole app is simply connect to mysql database and insert data using Entityframework. the code works well locally but when i upload in my amazon server, it just give me this error: you can see at http:\/\/fb1.131x.com\/test_data.aspx Description: An unhandled exception occurred during the execution of the current web request. Please review the stack [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1949","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1949","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1949"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1949\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}