NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 10 11 12 13 14 … 93 Next »
The node to be inserted is from a different document context

 
  • 0 Vote(s) - 0 Average
The node to be inserted is from a different document context
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#1
2012-01-28, 07:01 PM
Right, time to get to the bottom of this bugger. I've seen this error with a couple of my plugins now, but seeing as they were all written in the same way that's hardly surprising Rolleyes

Here's the first block of code that runs when the System plugin saves its settings (after clicking ok in the Settings dialog):
Code:
string path = "/Settings/PluginSettings/System";

SettingsHelper sh = SettingsHelper.GetInstance();
XmlDocument doc = sh.GetBackingDocument();
XmlNode system = sh.GetSettingsNode(path);

// Clear the current <System> node (if it exists)
if (system != null)
   system.RemoveAll();
// Otherwise, create it
else
{
   system = doc.CreateElement("System");
   sh.GetSettingsNode("/Settings/PluginSettings").AppendChild(system);
}

//Now (re)fill it with data
system.AppendChild(doc.CreateElement("ConfirmShutdownMode"));
// More similar lines follow...
...

"System.ArgumentException: The node to be inserted is from a different document context", "at System.Xml.XmlNode.AppendChild(XmlNode newChild)" is thrown - very very rarely - when it hits that last line of code. Why?

If it was wrong, surely it would crap-out every time :confused:

Testing fixes is difficult because it's so rare. If I open/ok, open/ok, etc the Settings dialog enough times I can usually force it, but I'd love to get rid of it for good!

Iain
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#2
2012-01-28, 08:49 PM
Maybe do a bit less combined operations so you can debug it better.


Oh was going to follow that up, but just realised, you're getting the backingdocument to a xmlDocument doc but then continuing to do stuff on the SettingsHelper.

Perhaps get teh document, and then do all the createelements and appends on the doc not the sh.
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,770
Threads: 954
Joined: May 2006
#3
2012-01-28, 09:09 PM
I never trusted config.xml as a source for my plugin's xml files. It is now being updated by NextPVR (TV Groups, online updates, and decoders come to mind) and with MVP and NMT's this could be multi-user, so I prefer distancing myself from it.

Martin
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#4
2012-01-28, 09:20 PM
psycik Wrote:Perhaps get teh document, and then do all the createelements and appends on the doc not the sh.

Same object though aren't they? I always assumed SettingsHelper was just sub's collection of "helper" methods for dealing with the document. My reference to doc should be the same as the one in SettingsHelper.

@Martin: hmm, might be worth trying it externally just to see, but I do find it handy to put stuff there - it's one less thing for the user to worry about if the settings all stay together.

Iain
Jaggy
Offline

Posting Freak

Carterton, NZ
Posts: 3,624
Threads: 148
Joined: Mar 2006
#5
2012-01-28, 10:19 PM
imilne Wrote:@Martin: hmm, might be worth trying it externally just to see, but I do find it handy to put stuff there - it's one less thing for the user to worry about if the settings all stay together. Iain

Before I comment I'm not actually in a "Pick on Iain" mode it's just there have been a few things you have posted over the last few days that I have disagreed with & this is another one.....

I "personally" prefer if the config file for a plugin is in the plugin's own directory, firstly I find them easier to find if I need to edit them, secondly if for whatever reason I decide/need to change the NextPVR config.xml all I need to do (after it generates a new clean one) is go into settings & enable the plugins whereas if they are also in the NextPVR config I have to reinstall & reconfigure them...... just my 2c worth.
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#6
2012-01-28, 10:37 PM
Jaggy Wrote:Before I comment I'm not actually in a "Pick on Iain" mode it's just there have been a few things you have posted over the last few days that I have disagreed with & this is another one.....
Meow Big Grin

Jaggy Wrote:I "personally" prefer if the config file for a plugin is in the plugin's own directory, firstly I find them easier to find if I need to edit them, secondly if for whatever reason I decide/need to change the NextPVR config.xml all I need to do (after it generates a new clean one) is go into settings & enable the plugins whereas if they are also in the NextPVR config I have to reinstall & reconfigure them...... just my 2c worth.

I can understand that. I'm not keen on having separate config files for every plugin, but I'll certainly give it a try because of this problem. Am I the only plugin developer storing settings this way?

Iain
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#7
2012-01-29, 06:53 PM
Always difficult to tell with this sort of problem, but I've moved the settings to their own file and so far haven't seen the error again.

Iain
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#8
2012-01-30, 08:36 AM
I can actually see the advantage of plugins saving their data in the config.xml but I can also see problems with it.

I'm not sure if it was a particular version of gbpvr or npvr but I seem to remember some issues that devs had in the past which either meant their settings weren't being saved properly or worse, even corrupting the config.xml file itself (I may be wrong - the little grey cells are diminishing as time flies). I think that put a lot of devs off.

Personally I don't care either way as long as it works and as I keep 8 days of backups of all the essentials related to npvr (db, config.xml, logs, xmltv files etc) I can swap stuff back in place in a few minutes if anything goes wrong. Big Grin
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  GetConfigFormInstance XML document? bgowland 5 2,227 2008-06-12, 08:20 AM
Last Post: fluffykeith
  deleting an xml node reven 4 1,910 2005-01-13, 03:59 PM
Last Post: reven

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode