I am facing the error "cannot assign void to an implicitly-typed variable" while writing the object in memory stream. below is my code