If you execute the same code later somewhere (let's say in page's controller action).. Do you see the same error?
Hi Valdis,
If i move the code to later when i use it. it initialize but it is still not working later. Same error. Any Idea?
This is probably a bug after breaking changes in CMS 8. http://world.episerver.com/documentation/Items/Upgrading/EPiServer-CMS/8/Breaking-changes/changes-to-the-category-api/
ServiceLocator.Current.GetInstance<CategoryRepository>().Get(6916); //Works
if I iterate ServiceLocator.Current.GetInstance<CategoryRepository>().GetRoot().FindChild("MYCATEGORY");// Throws error
if I iterate ServiceLocator.Current.GetInstance<CategoryRepository>().GetRoot().Categories i find my category
ServiceLocator.Current.GetInstance<CategoryRepository>().Get(AnyCategoriInTop) //works
We have totaly 396 Categories.
Bug Episerver?
I got this from Episerver Support:
The problem occurred because you have duplicate category names under the same node. Please remove them (either in the Admin mode, or directly from the table tblContent in the database). You can check the duplicated category names with this SQL command:
SELECT CategoryName, fkParentId, COUNT(CategoryName) FROM [dbHolmen_v8].[dbo].[tblCategory] GROUP BY CategoryName, fkParentId HAVING COUNT(CategoryName) > 1
Upgrade from CMS 7.19.2 to 8.11
I have this problem in initialisation of an ContentProvider
CODE in Constructor: myForestCategory = ServiceLocator.Current.GetInstance().Get("MYCATEGORY");
It is the Get function not working. Why? "MYCATEGORY" exists as a Category