Destabilization Error on Latest

Sep 17, 2012 at 4:16 PM
Edited Sep 17, 2012 at 4:16 PM

Sorry but I posted in the issue tracker when I should have posted here instead

I just added the latest Version of Json.NET (4.5 Release 9) and I get the System.Security.VerificationException: Operation could destabilize the runtime error when trying to use a controller (while running the application). I read in other posts that this issue should have been fixed in release 6 but I still have the problem. I even added *Newtonsoft.* to the ignore modules in the intellitrace options, which seems to have suppressed the error, but the post will just run forever and not return anything. One this to note is that this only happens on my localhost, and when using on my server, it appears to be working just fine.

Any help I can get would be greatly appreciated.



Code:
[HttpPost]
public string GetComments(int ShowID, int Page)
{
int PageSize = 10;

UserRepository UserRepo = new UserRepository();
ShowCommentViewModel viewModel = new ShowCommentViewModel();
IQueryable<Comment> CommentQuery = showRepository.GetShowComments(ShowID);
var paginatedComments = new PaginatedList<Comment>(CommentQuery, Page, PageSize);
viewModel.Comments = new List<CommentViewModel>();
foreach (Comment comment in CommentQuery.Take(10).ToList())
{
CommentViewModel CommentModel = new CommentViewModel
{
Comment = comment,
PostedBy = UserRepo.GetUserProfile(comment.UserID)
};

IQueryable<Comment> ReplyQuery = showRepository.GetShowCommentReplies(comment.CommentID);
int ReplyPage = 0;
var paginatedReplies = new PaginatedList<Comment>(ReplyQuery, ReplyPage, 3);
CommentModel.Replies = new List<ReplyModel>();

foreach (Comment reply in ReplyQuery.Take(3).ToList())
{
ReplyModel rModel = new ReplyModel
{
Reply = reply,
PostedBy = UserRepo.GetUserProfile(reply.UserID)
};

CommentModel.Replies.Add(rModel);
}

CommentModel.RepliesNextPage = paginatedReplies.HasNextPage;
CommentModel.RepliesPeviousPage = paginatedReplies.HasPreviousPage;
CommentModel.RepliesTotalPages = paginatedReplies.TotalPages;
CommentModel.RepliesPageIndex = paginatedReplies.PageIndex;
CommentModel.RepliesTotalCount = paginatedReplies.TotalCount;
viewModel.Comments.Add(CommentModel);

}


viewModel.CommentsNextPage = paginatedComments.HasNextPage;
viewModel.CommentsPeviousPage = paginatedComments.HasPreviousPage;
viewModel.CommentsTotalPages = paginatedComments.TotalPages;
viewModel.CommentsPageIndex = paginatedComments.PageIndex;
viewModel.CommentsTotalCount = paginatedComments.TotalCount;

return JsonConvert.SerializeObject(viewModel, Formatting.Indented);
}

Sep 17, 2012 at 6:52 PM

I fixed this by disabling lazy loading