Windows Control Library - Xml Serialization exception

Apr 26 2008 3:58 PM
Hi Friends,

I am facing problem in Serializing one of my type C# (.Net 2.0). It has only three properties to serialize
1. String
2. String
3. List<String>

I have very simple class as below

    [XmlRoot("LaunchConfig")]
    public class LaunchConfigData
    {
        #region Members

        string exeName = string.Empty;
        string downloadPath = string.Empty;
        List<string> dependencies = new List<string>();

        #endregion

        #region Properties

        [XmlElement("ExeName")]
        public string ExeName
        {
            get
            {
                return exeName;
            }

            set
            {
                exeName = value;
            }
        }

        [XmlElement("DownloadPath")]
        public string DownloadPath
        {
            get
            {
                return downloadPath;
            }

            set
            {
                downloadPath = value;
            }
        }

        [XmlArray("Dependencies")]
        [XmlArrayItem("Dependency")]
        public List<string> Dependencies
        {
            get
            {
                return dependencies;
            }

            set
            {
                dependencies = value;
            }
        }

        #endregion
 

}

I am trying to serialize and deserialize this type but not able to achieve the same in my existing project.

If I create similar class in any new project, it works fine without any problem. But if I try to use the same class in my Windows Control Library (within one of my UserControl), it throws exception as mentioned below.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Message: {"There is an error in XML document (0, 0)."}

Stack Trace: "   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)\r\n   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)\r\n   at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)\r\n   at Asyst.VAO.Vis.StatServer.ClientSIde.LaunchControls.XmlSerializeManager`1.Deserialize(String xmlData) in D:\\Dashboard_DB\\Src\\VAOVisualizer\\StatServer0408\\ClientSIde\\LaunchFabControl\\LaunchManager.cs:line 69"

Target : {System.Object Deserialize(System.Xml.XmlReader, System.String, System.Xml.Serialization.XmlDeserializationEvents)}

FileName: "LaunchFabControl, Version=1.0.3037.34063, Culture=neutral, PublicKeyToken=c7a19e454c6fc2e3"
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The InnerExceptions detail is...

Inner Exception: {"Could not load file or assembly 'LaunchFabControl, Version=1.0.3037.34063, Culture=neutral, PublicKeyToken=c7a19e454c6fc2e3' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))":"LaunchFabControl, Version=1.0.3037.34063, Culture=neutral, PublicKeyToken=c7a19e454c6fc2e3"}

Message: "Could not load file or assembly 'LaunchFabControl, Version=1.0.3037.34063, Culture=neutral, PublicKeyToken=c7a19e454c6fc2e3' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))"

Source: "pltrgao4"

Target Site: {System.Object Read3_LaunchConfig()}

StackTrace: "   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLaunchConfigData.Read3_LaunchConfig()"
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Also there is InnerException to this as...

Inner Inner Exception: {"Object reference not set to an instance of an object."}

Message: "Object reference not set to an instance of an object."

Stack Trace: "   at Microsoft.VisualStudio.Tools.UserControlTestContainer.OnAssemblyResolve(Object sender, ResolveEventArgs e)\r\n   at System.AppDomain.OnAssemblyResolveEvent(String assemblyFullName)"

TargetSite: {System.Reflection.Assembly OnAssemblyResolve(System.Object, System.ResolveEventArgs)}

Source: "pltrgao4"

Stack Trace (Inner) : "   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLaunchConfigData.Read3_LaunchConfig()"

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I have dll LaunchFabControl.dll within which I am having UserControl and this class. But at the time of Serialization and Deserialization of above class in this dll it throws above exception stating that the dll could not be loaded. How within the same dll it is not able to do the same. My dll is having strong name. Does it has anything related to this?

Also most of the times the XmlSerialization function like Serialize and Deserialize never returns from the call and my control hangs up. But some times ony it throws above exception. I tired of trying different approaches. I can go with simple writing and reading the xml file. But in this dll, many times the Load method of XmlDocument also behaves this way and the call to Load() never comes back to debugging file and it gets hang up somewhere.

I am not getting why this class works very well in other projects and dlls but within UserControl library having strong name it behaves like this???

Thanks for your help in advance.

Thanks

Answers (1)