Error: Failed to locate assembly (1 Viewer)

A

Anonymous

Guest
I'm writing a plugin that needs to be configured. In the configuration screen class it writes/reads its configuration data to/from an .xml-file. Whenever the plugin has executed the functions Xmlserializer.Deserialize() or Xmlserializer.Serialize, this error message appears:
"Failed to locate assembly 'LCD, Version 0.3. .... configuration program must be executed from/reside in the MediaPortal folder, the execution will now end."

- The (De)Serialize functions work perfectly
- No exception seems to be thrown
- The error appears only when the (De)Serialize functions succeed
- The error appears no matter where the .xml-file is located

Anybody any ideas on how i can store the configuration data of my plugin? The data is very nested and dynamic in size, so AMS.Profile or INI-Files can't be used.

Thanks
Harald

Edit: Cleaned up the text.
 
A

Anonymous

Guest
This is weird. The code runs perfectly if used in an .exe-file or in an assembly which is loaded by other apps - even MediaPortals runs with it.
Only MediaPortals Configuration.exe insists on having failed to locate the assembly (silly enough... :wink: ), so my code obviously is incompatible with something inside MediaPortals Configuration.exe.

Maybe someone finds the bug in this code snippet.
Any help is very appreciated!

Code:
namespace MP2LCD
{
	[Serializable]
	public class XMLScreens          // only there for serializing
	{
		[XmlElement(Type = typeof(TMeeScreenData))]
		public ArrayList Screen; // array of TMeeScreenData
	}

	public class MP2LCDSetup : ISetupForm
	{	
		public void ShowPlugin() 
		{
			ConfigureForm cf = new ConfigureForm();
			cf.ShowDialog();  // will get an error
		}
	}

	public class MP2LCDPlugin : IPlugin
	{
		public void Start() 		
		{
			ConfigureForm cf = new ConfigureForm();
			cf.ShowDialog(); //will run
		}
	}


	public class ConfigForm : System.Windows.Forms.Form
	{
		// ...

		public ArrayList ScrTyp;  // is basically a TMeeScreenData[]

		public ConfigForm()
		{
			InitializeComponent();

			int i;

			XMLScreens s = new XMLScreens();

			XmlSerializer ser = new XmlSerializer(typeof(XMLScreens));
			TextReader reader = new StreamReader("plugins\\process\\MP2LCD.screens.xml");
			try
			{
				s = (XMLScreens)ser.Deserialize(reader);	// fires MediaPortal error message when run by Configuration.exe

				ScrTyp = s.Screen;
			}
			catch 
			{
				ScrTyp.Clear();
			}
			finally
			{
				reader.Close();
			}
		}
	}
}
 

Weeji

Portal Member
March 14, 2009
44
8
I found that what caused this problem for me was a skin that I installed had installed a newer SVN version of MP-TVseries, which broke it as far as playing nicely with the non-SVN version of MediaPortal. Maybe that'll help.
 

v_kim

New Member
March 4, 2009
5
0
Home Country
Ukraine Ukraine
Failed to locate assembly

Has faced the same problem why there is this error? Somebody knows as to solve this problem? How to use xml Serialize - Deserialize from.dll?
Help!!!
 

FredP42

MP Donator
  • Premium Supporter
  • May 2, 2009
    237
    243
    78
    Home Country
    France France
    I had the same issue, and I finally found the solution in the code of the OnlineVideos plugin.

    XXX is the serialize type.
    Code:
    XXX ReadSettings()
    {
        XXX myobj = null;
    
        AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
        using (FileStream tr = new FileStream(file, FileMode.Open))
        {
            XmlSerializer xml = new XmlSerializer(typeof(XXX));
            myobj = (XXX)xml.Deserialize(tr);
        }
        AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
    
        return myobj;
    }
    
    System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
        foreach (System.Reflection.Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
        {
            if (asm.FullName == args.Name)
                return asm;
        }
        return null;
    }

    And then you have to use the sgen.exe tools (located in the .NET SDK directory C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin) to create an XML serialization assembly for your types.
     

    Users who are viewing this thread

    Top Bottom