Last night to implement a function, you need to store an object in the ViewState, but at run time, the following exception occurs.
Type ' Insus.NET.PictureObject ' in Assembly ' App_Code, version=0.0.0.0, culture=neutral, Publickeytoken=null ' are not Marked as serializable.
Description: An unhandled exception occurred during, the execution of the current Web request. Review the stack trace for more information about the error and where it is originated in the code.
Exception Details: System.Runtime.Serialization.SerializationException:Type ' Insus.NET.PictureObject ' in Assembly ' App_Code, version= 0.0.0.0, Culture=neutral, Publickeytoken=null ' is not marked as serializable.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Workaround, add a property before this class:
[Serializable]
Such as:
Type ' Insus.NET.PictureObject ' in Assembly ' App_Code, version=0.0.0.0, culture=neutral, Publickeytoken=null ' are not Marked as serializable.