November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi Torunn
A NullReferenceException can happen in a lot of places. It will be easier to pitch in, if you can post the stack trace of the exception.
The only stack trace is this:
Object reference not set to an instance of an object.
at EPiServer.Data.Dynamic.Internal.EPiServerDynamicDataStoreFactory.GetStore(Type type)
It should update the store in the database, and add the new field. But instead, it seems to complain that the store doesn't comply with the code.
It worked in test, but not in production. I copied the database from production to development, and the same error occurs there. The store doesn't have a name set in code,
and if I do, it also fails with the same exception.
So after digging some more, the error seems to be there before I add the new property.
It can't remap.
ingredientStore.StoreDefinition.Remap(ingredientType);
try
{
ingredientStore.StoreDefinition.CommitChanges();
}
catch (NullReferenceException exc)
{
The stack trace is:
at EPiServer.Data.Dynamic.Providers.SqlServerDataStoreProvider.GetStoreInfoSaveCommand(StoreDefinition storeDefinition)
at EPiServer.Data.Dynamic.Providers.SqlServerDataStoreProvider.<>c__DisplayClass36_0.<SaveStoreDefinition>b__0()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass32_0.<ExecuteTransaction>b__0()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass33_0`1.<ExecuteTransaction>b__0()
at EPiServer.Data.Dynamic.StoreDefinition.<>c__DisplayClass87_1.<CommitChanges>b__1()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass32_0.<ExecuteTransaction>b__0()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass33_0`1.<ExecuteTransaction>b__0()
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
at EPiServer.Data.Dynamic.StoreDefinition.<>c__DisplayClass87_0.<CommitChanges>b__0()
at EPiServer.Data.Cache.Internal.LocalCache`2.Add(TKey key, Boolean cacheNullValues, Boolean overwriteExistingValue, Func`1 getAction, Action`2 setAction)
at EPiServer.Data.Cache.Internal.LocalCache`2.Add(TKey key, Boolean cacheNullValues, Boolean overwriteExistingValue, Func`1 action)
at EPiServer.Data.Dynamic.StoreDefinition.CommitChanges(DataStoreProvider provider)
at ...IngredientsInitialization.Initialize(InitializationEngine context) in ...\IngredientsInitialization.cs:line 49
I even tried to clear the cache.
CacheProvider.Instance.ClearStore(ingredientStore.StoreDefinition.StoreName);
Any help is appreciated!
You can try to fall back to create store if getstore returns null. Something like
var store = GetStore(type) ?? CreateStore(type)
Hi!
I am really stuck at something. I am trying to add a new property to an existing DynamicDataStore, but if I do, I get a nullreference exception on
the get store call:
My class looks like this, and I am trying to add the PluralName property:
I have tried to add an initialization module that remaps the store, but no luck.
What am I doing wrong?