NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 35 36 37 38 39 … 93 Next »
XMLSerializer Problems with Plugins

 
  • 0 Vote(s) - 0 Average
XMLSerializer Problems with Plugins
ralphy
Offline

Senior Member

Posts: 255
Threads: 51
Joined: Nov 2006
#1
2007-10-13, 01:33 PM
I’ve come across two problems using the xmlserializer in my plugin. This first one I can work around (but don’t understand why it is occurring and the solution is not elegant), but the second has got me stumped.

First Problem.

Unless I include a copy of the plugin dll in the gbpvr folder as well as the plugins\common folder, PVRX2 throws the following exception then when executing
settings = (Settings)ser.Deserialize(rdr);

Code:
System.InvalidOperationException: There is an error in XML document (0, 0). ---> System.TypeInitializationException: The type initializer for 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSettings' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSettings..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSettings..ctor()
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract.get_Reader()
   at System.Xml.Serialization.TempAssembly.InvokeReader(XmlMapping mapping, XmlReader xmlReader, XmlDeserializationEvents events, String encodingStyle)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
   at ProcessPlugins.ExternalDisplay.Settings.Load() in y:\SharpDevelop Projects\External Display\ExternalDisplayPlugin\Settings.cs:line 513

It would appear the GBPVR and PVRX2 require the plugin DLL be in the GBPVR folder for the xmlserializer to work. I don't get this error if the dll is in both the GBPVR folder and the plugins\common or plugins\legacy folder

Second Problem.
So I copy my dll in to the GBPVR folder but when the plugin gets to
settings = (Settings)ser.Deserialize(rdr);

I get in the following log message:
Looking for missing assembly in plugin\common: ExternalDisplay.XmlSerializers, Version=0.0.2842.37635, Culture=neutral, PublicKeyToken=null

(My plugin is ExternalDisplay.dll)

Interestingly, the deserializer is working ok for the first couple of lines of the xml file that contain XMLAttributes, but then crashes when trying to deserialize an XMLElement– and only when run as a plugin. It works fine as a console app, so I know the code and xml file are correctly working.:confused:

Now for some reason, I am unable also unable to use sgen to create an ExternalDisplay.xmlseralizers file. I get an “Unable to load one or more of the requested types” error, so I can’t even create this file to put in the plugins\common folder to see if that would solve the problem. Googling the error message offers no obvious solutions to the problem.

So my questions are:
  1. why can't I deserializer the XMLElements as a plugin, but when the code is run as a console app, it deserializes perfectly? (I think it might be related to the next question)
  2. why does PVRX2 appear to expect to find the plugin.xmlserializers in plugins\common? I thought that using sgen to create this file is only required for optimisation, and that the xmlserializer will work without the file, generating it ‘on the fly’ from the dll. (I am almost certain this is the case, because I can run my code as a console application without errors – the config.xml file can deserialized; be modified by my console app; and then serialized and saved back to the file correctly, but the file cannot be loaded/deserialized when the code is run as a plugin)
  3. how can I resolve the error I get with sgen?
  4. why does PVRX2 seem to require the plugin dll to be in the GBPVR folder in order for the xmlserializer to work.
  5. how can I get the xmlserializer to work properly as a plugin?

The last question is the most important oneSmile
[SIZE="1"]Silverstone GD01S-MXR (three dead rows of pixels in the LCD and defective remote control), Power: Zalman ZM460B-APS (blew up - can't remember what's there now); CPU: Pentium D 3.2 GHz with Asus V72 Cooler; MD: Asus P5LD2 Deluxe 2048MB,
WDC WD10EADS 1TB Data, 320GB System, Asus EN9400GT Silent 512MB, Hauppauge HVR 1300,
XP Home SP3, GB-PVR 2.0, ExternalDisplay v0.3[/SIZE]
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 106,729
Threads: 767
Joined: Nov 2003
#2
2007-10-13, 07:38 PM
If you can supply me the DLLs and skin files, I'll try it here to see if I can work why it is trying to load from there, and see if I can improve it for the next release.
ralphy
Offline

Senior Member

Posts: 255
Threads: 51
Joined: Nov 2006
#3
2007-10-14, 01:50 AM
Thanks sub, I've emailed to support@gbpvr.com, hoping that'll work for you.
[SIZE="1"]Silverstone GD01S-MXR (three dead rows of pixels in the LCD and defective remote control), Power: Zalman ZM460B-APS (blew up - can't remember what's there now); CPU: Pentium D 3.2 GHz with Asus V72 Cooler; MD: Asus P5LD2 Deluxe 2048MB,
WDC WD10EADS 1TB Data, 320GB System, Asus EN9400GT Silent 512MB, Hauppauge HVR 1300,
XP Home SP3, GB-PVR 2.0, ExternalDisplay v0.3[/SIZE]
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 106,729
Threads: 767
Joined: Nov 2003
#4
2007-10-14, 03:33 AM
ralphy Wrote:Thanks sub, I've emailed to support@gbpvr.com, hoping that'll work for you.
Sorry, thats not a valid email address. I'm PM you my email address.
ralphy
Offline

Senior Member

Posts: 255
Threads: 51
Joined: Nov 2006
#5
2007-10-29, 01:59 PM
ralphy Wrote:why does PVRX2 appear to expect to find the plugin.xmlserializers in plugins\common?
It looks like PVRX2 actually looks for plugin.xmlserializers.dll in ..\gbpvr first, and then starts looking in other folder[s]. If it can't find anything, then the error message is printed.

ralphy Wrote:how can I resolve the error I get with sgen?

"Unable to load one or more of the requested types"
My bad - it turns out that all referenced assemblies needed to be in the same folder as the plugin.dll, so that when I typed c:\temp\sgen plugin.dll; all the referenced assemblies need to be in c:\temp.


Well, that's some progress on understanding what's going on with two out of the five questions. Unfortunately, Q1 and Q5 are still the burning!
[SIZE="1"]Silverstone GD01S-MXR (three dead rows of pixels in the LCD and defective remote control), Power: Zalman ZM460B-APS (blew up - can't remember what's there now); CPU: Pentium D 3.2 GHz with Asus V72 Cooler; MD: Asus P5LD2 Deluxe 2048MB,
WDC WD10EADS 1TB Data, 320GB System, Asus EN9400GT Silent 512MB, Hauppauge HVR 1300,
XP Home SP3, GB-PVR 2.0, ExternalDisplay v0.3[/SIZE]
ralphy
Offline

Senior Member

Posts: 255
Threads: 51
Joined: Nov 2006
#6
2008-02-16, 06:24 AM
ralphy Wrote:So my questions are:
  1. why can't I deserializer the XMLElements as a plugin, but when the code is run as a console app, it deserializes perfectly? (I think it might be related to the next question)
  2. why does PVRX2 appear to expect to find the plugin.xmlserializers in plugins\common? I thought that using sgen to create this file is only required for optimisation, and that the xmlserializer will work without the file, generating it ‘on the fly’ from the dll. (I am almost certain this is the case, because I can run my code as a console application without errors – the config.xml file can deserialized; be modified by my console app; and then serialized and saved back to the file correctly, but the file cannot be loaded/deserialized when the code is run as a plugin)
  3. how can I resolve the error I get with sgen?
  4. why does PVRX2 seem to require the plugin dll to be in the GBPVR folder in order for the xmlserializer to work.
  5. how can I get the xmlserializer to work properly as a plugin?

The last question is the most important oneSmile

ralphy Wrote:Well, that's some progress on understanding what's going on with two out of the five questions. Unfortunately, Q1 and Q5 are still the burning!

The solution was to replace all generic List objects being serialised with ArrayLists. Thanks Ommina for the pointer. See here
[SIZE="1"]Silverstone GD01S-MXR (three dead rows of pixels in the LCD and defective remote control), Power: Zalman ZM460B-APS (blew up - can't remember what's there now); CPU: Pentium D 3.2 GHz with Asus V72 Cooler; MD: Asus P5LD2 Deluxe 2048MB,
WDC WD10EADS 1TB Data, 320GB System, Asus EN9400GT Silent 512MB, Hauppauge HVR 1300,
XP Home SP3, GB-PVR 2.0, ExternalDisplay v0.3[/SIZE]
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#7
2008-02-16, 02:54 PM
ralphy Wrote:The solution was to replace all generic List objects being serialised with ArrayLists. Thanks Ommina for the pointer. See here
I ran across the issue again in another app I did. I found out that if there is no default constructor on the class, it can cause this. Make sure the class you are serializing (and subclasses) have a default constructor even if it is empty.

Quote:class MyClass
{
public MyClass() { }
}

After adding those, deserialization worked. I have not tried that fix in the original plugin where I ran across the issue but I'm pretty sure it would allow the List<> to work there as well.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Plugins and NPVR. Where do we start? sub 80 69,137 2020-11-26, 10:02 PM
Last Post: mandai
  Problems with Windows UWP App spitefulgod 4 3,838 2016-12-15, 08:35 PM
Last Post: spitefulgod
  I want to start developing plugins...but how? OrenShapir 6 4,096 2014-11-18, 10:38 PM
Last Post: mvallevand
  Tuner plugins and client id mvallevand 2 2,080 2013-07-03, 01:39 AM
Last Post: mvallevand
  Tuner Plugins - Output folders mvallevand 2 2,054 2013-02-19, 07:45 PM
Last Post: mvallevand
  Key press problems imilne 13 4,902 2013-01-02, 04:05 PM
Last Post: imilne
  .NET 4 plugins? McBainUK 20 7,787 2012-12-11, 08:48 PM
Last Post: sub
  Integrated Development Environment (IDE) for plugins osx-addict 5 2,779 2012-10-18, 08:35 PM
Last Post: osx-addict
  Plugin problems with started from the command line mvallevand 11 5,043 2012-08-12, 07:56 PM
Last Post: sub
  Tuner plugins mvallevand 4 2,462 2012-08-05, 11:19 PM
Last Post: mvallevand

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

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

Linear Mode
Threaded Mode