none
Error to deserialize The InnerException message was 'ValueType 'System.Int32' cannot be null RRS feed

  • Question

  • I am getting this error sporadically (it happened all the time about 2 hours ago, but now I am not getting the error) when bring up K2 forms (that uses K2 SmartObjects that calls WCF Service).
    When I kept getting the error, it seems to be at different functions

       http://tempuri.org/:GetAccountDetailsForWorkflowResult
       http://tempuri.org/:GetNewAccountFormInitializationDataResult
     
    The InnerException message was always the same: 'ValueType 'System.Int32' cannot be null.'

        Error: The formatter threw an exception while trying to deserialize the    message: There was an error while trying to deserialize parameter http://tempuri.org/:GetAccountDetailsForWorkflowResult. The InnerException message was 'ValueType 'System.Int32' cannot be null.'. Please see InnerException for more details.

    Why did I get this error 2 sporadically for the same workflow/form, sometimes I get the error sometimes I don't get the error ?
    Also, we tested the same workflows and service on 2 testing environments, and it works with no error.

    Could it be a problem with the network or the server ?

    How do I find what variables gives the error The InnerException message was 'ValueType 'System.Int32' cannot be null.' ?

    We just deployed a new WCF service yesterday, and the only think that may be related with System.Int32 and null is:
    I added a new field in 1 of the class Sponsor.cs (Sponsor is a table in our database, we are using EntityFramework CodeFirst Migration).
    The new field is:
    public int? numFO { get; set; }

    Could it be causing the error ? But, why the error doesn't happen all the time ?
    Saturday, December 10, 2016 11:58 PM

Answers

  • It looks like we found the problem, but we don't know 100% until the end of today.
    In one of our object AccountDetailsDto, FO used to be int, but I changed it for this deploy to be ?int.

    public class AccountDetailsDto
    {
        public int ?FO { get; set; }

    Our WCF service is located in 2 servers (for load balancing). When it was deployed on Friday, the service in 1 of the server was refreshed, but the service in the other server wasn't refreshed.
    So, yesterday night we refreshed the service in both servers. So far that seems to fix the issue.
    It makes sense why yesterday the problem was sporadic, sometimes it happened sometimes it didn't happen. When it worked, it must have hit the server that was refreshed on Friday. When it didn't work, it must have hit the server that wasn't refreshed. Also it makes sense why it worked on both of our test environments, because on test environments I always refreshed the service on both servers.

    According to this article: http://stackoverflow.com/questions/6677546/problem-with-linq-model-cant-assign-null-to-nullable-boolean

    The problem was caused by an out of date service reference on my client, so whilst the service had a nullable bool field, the proxy on the client was still expecting a regular bool field, hence the serialization exception.

    Make sure your service references in your client projects are up to date, my problem was caused by a conflict between the data contracts exposed by my service being different to those expected by the client.

    Also http://stackoverflow.com/questions/25168165/cant-return-null-system-boolean-cannot-be-null

    As Nullable<bool> field was introduced recently, reference on client side for my service wasn't updated. After updating the reference it worked.


    Sunday, December 11, 2016 2:13 PM

All replies

  • I am getting this error sporadically (it happened all the time about 2 hours ago, but now I am not getting the error) when bring up K2 forms (that uses K2 SmartObjects that calls WCF Service).
    When I kept getting the error, it seems to be at different functions

       http://tempuri.org/:GetAccountDetailsForWorkflowResult
       http://tempuri.org/:GetNewAccountFormInitializationDataResult
     
    The InnerException message was always the same: 'ValueType 'System.Int32' cannot be null.'

        Error: The formatter threw an exception while trying to deserialize the    message: There was an error while trying to deserialize parameter http://tempuri.org/:GetAccountDetailsForWorkflowResult. The InnerException message was 'ValueType 'System.Int32' cannot be null.'. Please see InnerException for more details.

    Why did I get this error 2 sporadically for the same workflow/form, sometimes I get the error sometimes I don't get the error ?
    Also, we tested the same workflows and service on 2 testing environments, and it works with no error.

    Could it be a problem with the network or the server ?

    How do I find what variables gives the error The InnerException message was 'ValueType 'System.Int32' cannot be null.' ?

    We just deployed a new WCF service yesterday, and the only think that may be related with System.Int32 and null is:
    I added a new field in 1 of the class Sponsor.cs (Sponsor is a table in our database, we are using EntityFramework CodeFirst Migration).
    The new field is:
    public int? numFO { get; set; }

    Could it be causing the error ? But, why the error doesn't happen all the time ?
    Saturday, December 10, 2016 11:36 PM
  • If this is related to WCF and the serialization and deserialization process for objects sent/received between WCF client and service, then maybe you should post to the WCF forum.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wcf

    Saturday, December 10, 2016 11:54 PM
  • Thanks. I just did that.

    But, maybe someone reading this forum have similar experience ?

    Sunday, December 11, 2016 12:00 AM
  • Thanks. I just did that.

    But, maybe someone reading this forum have similar experience ?


    I work with WCF all the time, and I have never seen it. If the property is a null value, then it should have put the word "NULL" in the value for the XML property tag.
    Sunday, December 11, 2016 1:05 AM
  • >If the property is a null value
    YOu mean this, right ?

    public int? numFO { get; set; }

    Where can I find the XML property tag ?

    The weird thing is the problem happens sometimes, sometimes works.
    And, the same code works in 2 other environments (test environments)

    Sunday, December 11, 2016 2:07 AM
  • >If the property is a null value
    YOu mean this, right ?

    public int? numFO { get; set; }

    Where can I find the XML property tag ?

    The weird thing is the problem happens sometimes, sometimes works.
    And, the same code works in 2 other environments (test environments)

    I am talking in general how XML serialization works for an object that has public properties, which you'll never see this working as this is internal WCF functionality.

    The thing that you maybe able to do start XML serializing the objects just befor WCF does it to see if can spot something sending the data to a logfile, possibly.

    I would say someone in the WCF forum could maybe tell of a way of exposing the problem.

     And your property example is what I am talking about that could be a null value that is being serialized.
    Sunday, December 11, 2016 5:34 AM
  • It looks like we found the problem, but we don't know 100% until the end of today.
    In one of our object AccountDetailsDto, FO used to be int, but I changed it for this deploy to be ?int.

    public class AccountDetailsDto
    {
        public int ?FO { get; set; }

    Our WCF service is located in 2 servers (for load balancing). When it was deployed on Friday, the service in 1 of the server was refreshed, but the service in the other server wasn't refreshed.
    So, yesterday night we refreshed the service in both servers. So far that seems to fix the issue.
    It makes sense why yesterday the problem was sporadic, sometimes it happened sometimes it didn't happen. When it worked, it must have hit the server that was refreshed on Friday. When it didn't work, it must have hit the server that wasn't refreshed. Also it makes sense why it worked on both of our test environments, because on test environments I always refreshed the service on both servers.

    According to this article: http://stackoverflow.com/questions/6677546/problem-with-linq-model-cant-assign-null-to-nullable-boolean

    The problem was caused by an out of date service reference on my client, so whilst the service had a nullable bool field, the proxy on the client was still expecting a regular bool field, hence the serialization exception.

    Make sure your service references in your client projects are up to date, my problem was caused by a conflict between the data contracts exposed by my service being different to those expected by the client.

    Also http://stackoverflow.com/questions/25168165/cant-return-null-system-boolean-cannot-be-null

    As Nullable<bool> field was introduced recently, reference on client side for my service wasn't updated. After updating the reference it worked.


    Sunday, December 11, 2016 2:13 PM
  • Hi aujong,

    Thank you for posting here.

    According to your question is more related to WCF, I will move it to WCF Forum for suitable support.

    The Visual C# Forum discuss and ask the question about the C# programming language, IDE, libraries, samples and tools.

    If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Thanks for your understanding and cooperation.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 12, 2016 2:50 AM
  • Hi aujong,

    I am glad your issue has been resolved, and thanks for sharing the solution. I would suggest you mark your reply as answer, and then others who run into the same issue would find the solution easily.

    If you have any other issues related with WCF, please feel free to post in this forum.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 12, 2016 5:10 AM
  • Thanks all for your help
    Monday, December 12, 2016 12:36 PM