Skip to content

Version 9.0: List<int> seems to always be nulled in transit #4680

Description

@rsemparnell

Describe the bug
One of my business objects has a List property. It appears to always be lost by the serializer - while my Create() method is RunLocal, the call to Insert() results in a null reference exception when the property is encountered. Even explicitly initializing and optionally setting a test value still results in a null.

The upgrading to v9 document seems to imply that List is explicitly supported?

Version and Platform
CSLA version: 9.0.0
OS: Windows
Platform: ASP.NET Core MVC

Code that Fails

public static readonly PropertyInfo<List<int>> AllowedPurposeIdsProperty = 
    RegisterProperty<List<int>>(c => c.AllowedPurposeIds);

public List<int> AllowedPurposeIds
{
    get => GetProperty(AllowedPurposeIdsProperty);
    set => SetProperty(AllowedPurposeIdsProperty, value);
}

Then the code that sets it:

var NewFolderObj = dataPortalFactory.GetPortal<FileFolder>().Create();
NewFolderObj.FolderName = entry.Name;
NewFolderObj.ModuleID = ModuleID;
NewFolderObj.GroupID = GroupID;
NewFolderObj.Deleted = false;
NewFolderObj.FolderOwnerID = FolderOwnerID;
NewFolderObj.AllowedPurposeIds = AllowedPurposeIds.ToList(); // stored locally as an array for annoying reasons

if (NewFolderObj.IsSavable)
{
    await NewFolderObj.SaveAndMergeAsync();
...

Stack Trace or Exception Detail
When I replaced the object with a string property, it works, but this is not ideal for type safety.

Additional context
Add any other context about the problem here.

Activity

  1. StefanOssendorf commented on May 30, 2025

    @StefanOssendorf
    Contributor

    Hi. List<T> is not serializable. You have to use MobileList<T> to get a list serialized. Same holds for MovileDictionary

  2. rsemparnell commented on May 30, 2025

    @rsemparnell
    Author

    Hi. List<T> is not serializable. You have to use MobileList<T> to get a list serialized. Same holds for MovileDictionary

    The documentation implies otherwise? A couple of my other objects use List<string> and List<int> and don't appear to be failing, but those are only being loaded up from the dal, not edited. This pitfall appears only to be on the client side when the client is setting or modifying the property. If it is not supported, but yet is implied that this type as a primitive should be, perhaps the v9 doc needs adjusted?

    Also sorry for the lack of pleasantries, I tend to be very dry and emotionless when I'm working - so hello, all.

    How you implement these methods is up to you, but you should be aware that the SerializationInfo class is a key/value store,
     so you can store any "primitive" data in it that can be normally serialized using MobileFormatter.
    
    This includes:
    
    All .NET primitive types
    string
    DateTime, TimeSpan, DateTimeOffset, DateOnly, TimeOnly
    Guid
    byte[]
    char[]
    List<int>
    
  3. StefanOssendorf commented on May 31, 2025

    @StefanOssendorf
    Contributor

    You are correct. The docs suggest that but I think this is out of the box not possible. Maybe @rockfordlhotka can shed some light on it. He wrote the new doc section :D

    Nevertheless with MobileList it should definitely work.

    Anyway I'll try your code if there's a bug.
    Could you please elaborate on the cases where it works? How's the object defined and which ways are the lists being sent?
    Thanks in advance

  4. rsemparnell commented on Jun 2, 2025

    @rsemparnell
    Author

    Ha! Yeah a documentation bug is what I have my money on.

    No worries, I already fixed the issue using a MobileList and did the same to the others just in case. Many thanks though, but perhaps we need a point of clarification and perhaps a modification to the document.

    Thanks!

  5. added 3 commits that reference this issue on Feb 14, 2026
    a427eb0
    2d606c5
    a6db156
  6. added a commit that references this issue on Feb 14, 2026
    2d6e439
  7. github-actions commented on Aug 16, 2026

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  8. locked as resolved and limited conversation to collaborators on Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions