OptionalFieldAttribute is causing AugumentNullException on Deseria

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SmFzb24=?=

    OptionalFieldAttribute is causing AugumentNullException on Deseria

    I have an application that includes several serializable classes that are all
    output using the SOAP formatter. Over the years, I've added several
    OptionalFieldAt tributes to various members of the classes.

    Now, on one particular class I'm trying to add an additional
    OptionalFieldAt tribute, but when I deserialize the objects I get an
    ArgumentNullExc eption with a message of: "Member at position 22 was null."

    I can move the new field to a different class and everything works just
    fine. This error only happens in the single class where I need this new
    attribute.

    This is the 8th OptionalField to be added to the class. The actual code is
    as follows:
    <OptionalFieldA ttribute(Versio nAdded:=6)Priva te _Status As Integer

    The top part of the stack trace includes the following:
    at
    System.Runtime. Serialization.F ormatterService s.PopulateObjec tMembers(Object
    obj, MemberInfo[] members, Object[] data)
    at
    System.Runtime. Serialization.F ormatters.Soap. ReadObjectInfo. PopulateObjectM embers()
    at
    System.Runtime. Serialization.F ormatters.Soap. ObjectReader.Pa rseObjectEnd(Pa rseRecord pr)
    at
    System.Runtime. Serialization.F ormatters.Soap. ObjectReader.Pa rse(ParseRecord
    pr)
    at
    System.Runtime. Serialization.F ormatters.Soap. SoapHandler.End Element(String
    prefix, String name, String urn)
    at System.Runtime. Serialization.F ormatters.Soap. SoapParser.Pars eXml()
    at System.Runtime. Serialization.F ormatters.Soap. SoapParser.Run( )
    at
    System.Runtime. Serialization.F ormatters.Soap. ObjectReader.De serialize(Heade rHandler handler, ISerParser serParser)
    at
    System.Runtime. Serialization.F ormatters.Soap. SoapFormatter.D eserialize(Stre am
    serializationSt ream, HeaderHandler handler)
    at
    System.Runtime. Serialization.F ormatters.Soap. SoapFormatter.D eserialize(Stre am
    serializationSt ream)
    at ... [my calling function]

    I've found a similar post at
    The home for technical questions and answers at Microsoft. Get started asking, answering, and browsing questions about products like .Net, Azure, or Teams.

    that did not include a resolution to the problem either.

    I'm trying to figure out how to handle this issue so I can serialize this
    additional field correctly and handle previously saved data files.

    Jason

  • Hongye Sun [MSFT]

    #2
    RE: OptionalFieldAt tribute is causing AugumentNullExc eption on Deseria

    Hi Jason,

    Thanks for using Microsoft Newsgroup Service. My name is Hongye Sun [MSFT]
    and it is my pleasure to work with you on this issue.

    After my research on this issue, I found that this issue as you described
    can be caused by many possibilities and it is hard to tell what caused the
    error right now. I need the serializable classes and the xml file that you
    are testing on to do further troubleshooting . Can send them to my email
    address (hongyes@online .microsoft.com, remove 'online.')?

    Here is information for you to do troubleshooting on your side:
    One possibility of the issue is caused by duplicate members in xml file. If
    there are two fields with same name in xml file, the SOAP formatter is
    unable to identify them and report the same exception as you reported.
    The duplicate members may look like:
    ---------------------------------
    <m_Image5 xsi:null="1"/>
    <m_Image5 xsi:null="1"/>
    ---------------------------------
    m_Image5 is one of the fields in the class.
    Can you have a quick check of the xml file and verify that there is no
    duplicate in all the members of the error class?

    Thanks in advance for your cooperation and I will be waiting for your
    reply. Have a nice day.

    Regards,
    Hongye Sun (hongyes@online .microsoft.com, remove 'online.')
    Microsoft Online Community Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subs...#notifications.

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at

    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.

    Comment

    • Hongye Sun [MSFT]

      #3
      RE: OptionalFieldAt tribute is causing AugumentNullExc eption on Deseria

      Hello Jason,

      Thanks for your reply email. The repro project is very useful for us to do
      further troubleshooting .

      I have done a deep research on the project and found the cause of the
      problem, however, I haven't found the solution yet. I am writing to let you
      know the progress of the issue and I will continue to work out a solution
      for you. In the meanwhile, I will also consult this issue with product team.

      The cause I found is that when a class has a structure field, the
      OptionalFieldAt tribute will stop working.

      I tested it in our lab by setting the fields in the clsSystem class to
      NonSerialized one by one and finally found that when mvarColor, which is
      type "Color" structure, is set to NonSerialized, everything works fine. (I
      also simplified the "ias" file.)

      I also proved that by creating another new class with a field whose type is
      a user defined structure. It reports me the same error.

      Thanks again for your great cooperation. Have a nice day!

      Regards,
      Hongye Sun (hongyes@online .microsoft.com, remove 'online.')
      Microsoft Online Community Support

      Delighting our customers is our #1 priority. We welcome your comments and
      suggestions about how we can improve the support we provide to you. Please
      feel free to let my manager know what you think of the level of service
      provided. You can send feedback directly to my manager at:
      msdnmg@microsof t.com.

      This posting is provided "AS IS" with no warranties, and confers no rights.

      Comment

      • Hongye Sun [MSFT]

        #4
        RE: OptionalFieldAt tribute is causing AugumentNullExc eption on Des

        You are welcome, Jason. It is my pleasure to work with you.

        We are still verifying if this is a bug. I will continue to update the
        progress of the issue in this thread. If you are not interested in the
        further information, please feel free to let me know. I will close this
        issue. Thanks.

        Regards,
        Hongye Sun (hongyes@online .microsoft.com, remove 'online.')
        Microsoft Online Community Support

        Delighting our customers is our #1 priority. We welcome your comments and
        suggestions about how we can improve the support we provide to you. Please
        feel free to let my manager know what you think of the level of service
        provided. You can send feedback directly to my manager at:
        msdnmg@microsof t.com.
         
        This posting is provided "AS IS" with no warranties, and confers no rights.



        Comment

        Working...