Q:

InvalidCastException when executing a select

I have a query that looks like this:
 surveyCompleted = from s in surveyCompleted 
                where agentTickets.Contains(s.TicketID.Value) || s.UserID == new Guid(txtUserID.Text) select s;

The problem is that after this statement I can't do anything with surveyCompleted because I get an InvalidCastException. Any ideas why this happens? All the other select statement with surveyCompleted work just fine but this one fails? Could it be from the statement "agentTickets.Contains(s.TicketID.Value)" in the where clause?

A:

If txtUserID is a TextBox (name leads to think so), then new Guid(txtUserID.Text) would throw if it's not containing a precise Guid-like string (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

