I have a LINQ -> Class file named MoviesDB.dbml, I have added one table “Movie” to it, i have created a class “Movies” in which i have implemented inside all the methods.
Method GetAllMovies which gets a List, when binding the list i get the following:
Type 'DyMvWebsite.Movie' in Assembly 'DyMvWebsite, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
The code for the Method:
public static List<Movie> GetAllMovies()
{
List<Movie> oMoviesList = new List<Movie>();
using (MoviesDBDataContext oMoviesDBDataContext = new MoviesDBDataContext())
{
oMoviesList = oMoviesList.ToList<Movie>(); ;
}
return oMoviesList;
}
After that i have tried putting the [Serializable] attribute in the “Movies” class and tried putting it in the linq designer file too, but same problem.
Edit:
After following what ‘Massimiliano Peluso’ suggested, i received a new error:
Type 'System.Data.Linq.ChangeTracker+StandardChangeTracker' in Assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
Try this out
before firing the query.
If this still fails, then the work around will be create serializable class similar to Movie class, and map the properties.