2011-12-01 68 views
0

我想用下面的代码的XPathNavigator引发错误引发NotSupportedException

private static bool ResetUpdateVersion() 
{ 
    // this indicate either the verwsion is different or not 
    // this will either call the update only or writting the defualt 
    bool Result = false; 
    //// check for version using xpath 
    XPathNavigator navigator = document.CreateNavigator(); 
    //ShortcutList is the main element that contain all the other elements 
    XPathNavigator node = navigator.SelectSingleNode(@"/ShortcutList"); 
    XmlNamespaceManager ns = new XmlNamespaceManager(navigator.NameTable); 
    if (node != null) 
    { 
     if (node.GetAttribute("Version", ns.DefaultNamespace) != Version) 
     { 
      node = navigator.SelectSingleNode(@"/ShortcutList/@Version"); 

      node.SetValue(Version); 

      Result = true; 
     } 
     else 
     { 
      Result = false; 
     } 
    } 

    return Result; 
} 

更新的XDocument,但上线node.SetValue(Version);提高NotSupportedException异常,我不知道为什么,任何想法来解决

+0

什么是版本?它在哪里定义? – FailedDev

回答