London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Author comparation issue

Vote:
0

[TestMethod]
public void CommunityAuthorTest()
{
//Any valid comment Id
const int validId = 1;

IComment comment = CommentHandler.GetComment(validId);
var author = comment.Author as GuestAuthor;
if(author != null) {//Exception at camparation
//Insert code
}
}

#38265
Apr 06, 2010 16:38
Vote:
0

What is the exception that you are getting?

#38266
Apr 06, 2010 16:55
Vote:
0

I get the same kind of exception trying to get the UserAuthor from a blog. If i do something like

var author = (UserAuthor)blog.Author;

it works fine (because so far the author is always a UserAuthor), but when I try to be polite and check like:

var author = blog.Author as UserAuthor;
if (author != null) // BOOM

I get a stack overflow exception from EPiServer.Common.Framework.Impl.dll (no further details because VS can't give them to me when the stack is in overflow).

If I remember correctly, constructs like

UserAuthor author = null;
if (blog.Author is UserAuthor) { author = (UserAuthor)blog.Author; }
if (author != null) ...

work just fine, but my memory could be playing tricks.

#38413
Apr 09, 2010 9:42
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.