none
MyAssembly.XmlSerializers.dll generated by sgen.exe causes error RRS feed

  • Question

  • Hi guys, 

    I come up with a very weird problem with MyAssembly.XmlSerializers.dll generated by sgen.exe. 

    Here is my deployment.

    MyAssembly.dll is put in a different folder as application folder but not GAC. My application loads MyAssembly.dll by calling Assembly.LoadFile. Everything works well. 

    Then I put the MyAssembly.XmlSerializers.dll into the application folder, I got an exception that saying unable to load assembly MyAssembly.dll in the constructor of XmlSerializer (Type type). How can it happen?

    NOTE: MyAssembly.dll defines all the types to serialize/de-serialize and include all the XmlSerializer to do the serialization. 

    Thanks,

    M


    • Edited by Michael ZH Tuesday, June 18, 2013 6:57 AM
    • Moved by Bob Shen Wednesday, June 19, 2013 7:29 AM
    Tuesday, June 18, 2013 6:57 AM

Answers

All replies

  • Here is part of the exception

    ---> System.IO.FileNotFoundException: Could not load file or assembly MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: MyAssembly, Version=1..0.0.0, Culture=neutral, PublicKeyToken=null'

    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract.CanSerialize(Type type)

    at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)

    at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)

    at System.Xml.Serialization.XmlSerializer..ctor(Type type)

    …….

    --- A detailed error log follows. ===

    Pre-bind state information === LOG: User = Administrator LOG: DisplayName = MyAssembly, Version=1..0.0.0 Culture=neutral, PublicKeyToken=null (Fully-specified)

    LOG: Appbase = file:///C:/Program Files (x86)/ XXX/XXX/

    LOG: Initial PrivatePath = NULL Calling assembly : MyAssembly.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. ===

    LOG: This bind starts in default load context.

    LOG: Using application configuration file: C:\Program Files (x86)\XXX\XXX\XXX.config

    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.

    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).

    LOG: The same bind was seen before, and was failed with hr = 0x80070002

    I notice that the calling assembly is MyAssembly.XmlSerializers. I cannot understand why since MyAssembly is already loaded in the process by Assembly.LoadFile. Why MyAssembly.XmlSerializers needs to load it again?

    Thanks,

    M

    Tuesday, June 18, 2013 10:05 AM
  • Hi Msts,

    I would like to redirect you to appropriate forum for better responses.


    Bob Shen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Michael ZH Wednesday, June 19, 2013 8:21 AM
    Wednesday, June 19, 2013 7:29 AM
  • Thanks for your remind, Bob. 

    I intended to post it on C# forum.

    M

    Wednesday, June 19, 2013 8:20 AM
  • Hi Msts,

    Please try this tool to find out why it cannot find the reference: http://msdn.microsoft.com/en-us/library/e74a18c4.aspx  

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, June 19, 2013 8:26 AM
    Moderator