Im trying to create an item programmatically on Sitecore, this is how to code looks like:
var db = Sitecore.Configuration.Factory.GetDatabase(dbName);
Item RepositoryItem = db.GetItem(repId, Sitecore.Context.Language);
TemplateID tid = new Sitecore.Data.TemplateID(new Sitecore.Data.ID(TemplateId);
Item newItem = RepositoryItem.Add(resource_name, tid);
newItem.Editing.BeginEdit();
newItem[resourceConstants.IndustryFieldName] = industry;
newItem[resourceConstants.MarketFieldName] = markets;
newItem[I_BUResourceConstants.ResourceIdFieldName] = resource_id;
newItem.Editing.EndEdit(true);
When the application is doing RepositoryItem.add im getting the following error: Value can not be null/ Parameter name cache.
This is the stacktrace
at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
at Sitecore.Data.DataProviders.Sql.SqlDataProvider.ResolvePathRec(String[] path, PathCache cache, CallContext context)
at Sitecore.Data.DataProviders.DataProvider.ResolvePath(String itemPath, CallContext context, DataProviderCollection providers)
at Sitecore.Nexus.Data.DataCommands.ResolvePathCommand.Execute(String , Database )
at Sitecore.Data.Engines.EngineCommand`2.Execute()
at Sitecore.Data.Managers.ItemProvider.GetItem(String itemPath, Language language, Version version, Database database, SecurityCheck securityCheck)
at Sitecore.Data.Managers.PipelineBasedItemProvider.<>c__DisplayClass2f.<GetItem>b__2e()
at Sitecore.Data.Managers.PipelineBasedItemProvider.ExecuteAndReturnResult[TArgs,TResult](String pipelineName, String pipelineDomain, Func`1 pipelineArgsCreator, Func`1 fallbackResult)
at Sitecore.Data.Managers.ItemManager.GetItem(String itemPath, Language language, Version version, Database database)
at Sitecore.Globalization.DictionaryDomain.GetDomainDefinitionItem(Database database, String name)
at Sitecore.Globalization.DictionaryDomain.TryParse(String domainDefinition, Database database, DictionaryDomain& domain)
at Sitecore.Globalization.DictionaryDomain.GetDefaultDomain(Database database)
at Sitecore.Pipelines.GetTranslation.TryGetFromContextDatabase.Process(GetTranslationArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Globalization.Translate.TextByLanguage(String domainName, TranslateOptions options, String key, Language language, String defaultValue, Object[] parameters)
at Sitecore.Globalization.Translate.TextByLanguage(String key, Language language, String defaultValue, Object[] parameters)
at Sitecore.Globalization.Translate.TextByLanguage(String key, Language language, String defaultValue)
at Sitecore.Globalization.Translate.TextByLanguage(String key, Language language)
at Sitecore.Data.Items.ItemUtil.GetItemNameError(String name)
at Sitecore.Data.Items.ItemUtil.IsItemNameValid(String name)
at Sitecore.Data.Items.ItemUtil.ProposeValidItemName(String name, String defaultValue)
at Sitecore.Data.Items.ItemUtil.ProposeValidItemName(String name)
at resource_import.AddResourceToRepository(String resource_id, String product_solution, String markets, String industry, String product_type, String resource_name, String resource_link, String resource_type) in C:\project\resource.aspx.cs
at resource_import.butSubmit_Click(Object sender, EventArgs e) in C:\project\resource.aspx.cs
I working on Sitecore 8.1 (rev. 151207), I have the same code working on sitecore 7.2
It looks like you are passing in an invalid item name. It is running validation on the name and returning an error message. It tries to translate the error message, but then another error occurs within the SQL data provider. It looks like it cannot find the path cache. Check to see of you have disabled caching using the Caching.Enabled setting.