mardi 10 mars 2015

NullReferenceException on TitleResource for SPNavigationNode



I keep getting a NullReferenceException when trying to access the TitleResource of an SPNavigationNode.



bool isExternal = false;
// assume anything starting with "http" is an external link
if (url.StartsWith("http", true, WebSiteInfo.en)) isExternal = true;

SPNavigationNode entry = new SPNavigationNode(nameEn, url, isExternal);

SPUserResource _userResource = entry.TitleResource;
_userResource.SetValueForUICulture(WebSiteInfo.fr, nameFr);
_userResource.Update();

SPNavigationNodeCollection quickLaunch = web.Navigation.QuickLaunch;
quickLaunch.AddAsLast(entry);


Things work fine if I remove the attempt to set the alternate language title, but then of course I don't have multilingual support on my entry.








0 commentaires:

Enregistrer un commentaire