Interestingly enough while developing a module on an ASP.NET web app, I've been storing some cached object data in the ViewState, some well defined and some not (ie: declaring them as dynamic
and initializing them as ExpandoObject
).
This works fine during development on my Windows 10 IIS 10 dev box but once I push this into a Windows Server Core 2016 with IIS 10 (running .NET 4.5, 4.6, 4.7 or 4.8) it doesn't work, I get the System.ArgumentException: Error serializing value 'System.Dynamic.ExpandoObject' of type 'System.Dynamic.ExpandoObject.' ---> System.Runtime.Serialization.SerializationException: Type 'System.Dynamic.ExpandoObject' in Assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
error.
I was wondering what could be making this work on the local environment and not on the server side given ExpandoObject
isn't serializable natively, so wondering how could my local environment be storing these objects in the viewstate and recovering them just fine?
Edit: Actually, all other objects I'm adding to the viewstate are also not marked serializable and are now starting to give problems on the server. How is it possible this works locally considering none of the objects being added to the viewstate are serializable?