November Happy Hour will be moved to Thursday December 5th.

Author comparation issue

Vote:
 

[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:
 

What is the exception that you are getting?

#38266
Apr 06, 2010 16:55
Vote:
 

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.