If you execute the same code later somewhere (let's say in page's controller action).. Do you see the same error?
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/
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
We have totaly 396 Categories.
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
It is the Get function not working. Why? "MYCATEGORY" exists as a Category