I am adding extra properties to a provider created by a colleague. I need the umbhelper to check for memberaccess to a resultpage in a search. Unfortunately i get an "value cannot be null" on the "public UmbracoHelper umbHelper = new UmbracoHelper(UmbracoContext.Current);" line.
How should i instantiate the helper so i can use it properly?
Just one thing that may be useful: it seems that your CreateObject method is already being passed an instance of the UmbracoHelper (see the helper parameter).
So you can probably just use that by changing that line as follows:
How to instantiate umbracohelper in my provider
I am adding extra properties to a provider created by a colleague. I need the umbhelper to check for memberaccess to a resultpage in a search. Unfortunately i get an "value cannot be null" on the "public UmbracoHelper umbHelper = new UmbracoHelper(UmbracoContext.Current);" line.
How should i instantiate the helper so i can use it properly?
Eternally grateful for any help possible.
Solved. I moved the instantiation inside the CreateObject class.
Just one thing that may be useful: it seems that your
CreateObject
method is already being passed an instance of the UmbracoHelper (see thehelper
parameter).So you can probably just use that by changing that line as follows:
to be:
and then just remove the
umbHelper
instantiation and property altogether.That's probably a better way of doing it, because creating instances of UmbracoHelper from UmbracoContext.Current is discouraged:
https://our.umbraco.com/documentation/reference/Common-Pitfalls/
is working on a reply...