「System.NullReferenceException」種類の最初のチャンス例外はCMS.GlobalHelper.dllエラーで発生しました。コードは、いずれかのページでNodeAliasPath
を更新する必要があります。Kenticoは7コンソールアプリケーション
// Create an instance of the Tree provider first
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
//Gets all the nodes that have the node alias path of Dinning-Commons
var nodes = tree.SelectNodes("SietName", "%contains part of nodealispath%", "en-us", false);
if (nodes != null)
{
// Loop through all documents
foreach (TreeNode node in nodes)
{
Console.WriteLine("NodeAliasPath before change " + node.NodeAliasPath);
file.WriteLine(" ");
file.WriteLine("NodeAliasPath before change " + node.NodeAliasPath);
Console.WriteLine(" ");
file.WriteLine(" ");
String newNodeAliasPath = node.NodeAliasPath.Replace("old node alias path", "new node alias path);
//Set the value this way
bool returnNodeValue = node.SetValue("NodeAliasPath", newNodeAliasPath);
Console.WriteLine(" returnNodeValue " + returnNodeValue);
//Or set value thos way
Console.WriteLine(" return value from Set Value -- NodeAlias Path " + node.SetValue("NodeAliasPath", newNodeAliasPath));
Console.WriteLine(" __________________________ ");
file.WriteLine(" return value from Set Value -- NodeAlias Path " + node.SetValue("NodeAliasPath", newNodeAliasPath));
file.WriteLine(" __________________________ ");
// Save to database----NULL REFERNCE IN CMSHELPER.DLL Here. Code hangs
node.Update();
Kenticoクラスを使用する前にAPIを初期化しましたか? http://stackoverflow.com/questions/34955846/using-kentico-7-api-via-console-app – rocky
はい> // Kentico APIを使用するためにコンソールアプリケーションを初期化します CMS.CMSHelper.CMSContext.Init(); – KenticoLover
初期化は何よりも先に行われます。プログラム全体がnode.updateポイントまで動作します – KenticoLover