Is ICloneable has something to do with the error: Unable to cast object of type 'X' to type 'Y'

Last post 07-05-2009 9:32 AM by Yovav. 2 replies.

Sort Posts:

  • Is ICloneable has something to do with the error: Unable to cast object of type 'X' to type 'Y'

    07-04-2009, 3:13 PM
    • Member
      698 point Member
    • Yovav
    • Member since 02-19-2003, 2:35 PM
    • Las Vegas
    • Posts 171

    I'm not sure what are the benefits of implementing ICloneable,

    my web site is trapping a strange error and I wonder if that might have something to do with it,

     

    The error is: Unable to cast object of type 'X' to type 'Y'

    Where X is one object and Y is a different object (does not make sense)

    I'm convinced that this is not a casting error on my side since its working fine locally and I only get this error occasionally... don't know how to reproduce it...

    My objects are all using [Serializable]

    I think its happening in some cases when I'm loading objects back from cache or from the application state,

     

    Also, this service class is being accessed as an instance (using a singleton) like this:

    LanguageService.Instance.Get(resourceName, languageId, LanguageResourceType.String);

    (this is generating the error)

    And it is being called using another static class like this: 

    Resources.String("SomeString");

     

    I would like to hear any suggestions or if you think there is something wrong here.

    Thanks in advance.

    10X N C U L8R
    Best Regards
    YovavG@GMail.com
  • Re: Is ICloneable has something to do with the error: Unable to cast object of type 'X' to type 'Y'

    07-05-2009, 2:52 AM
    • Contributor
      6,298 point Contributor
    • integrasol
    • Member since 06-05-2009, 3:18 PM
    • Posts 1,220

    This could have to do with the way the objects you use are treated on the server. The specific error you get, is it after retrieving from cache or application state? Is the server running the web site as a web farm or a web garden?

    Thanks

    Carsten

    Please mark this post as Answer if it is of help to you. :-)
  • Re: Is ICloneable has something to do with the error: Unable to cast object of type 'X' to type 'Y'

    07-05-2009, 9:32 AM
    Answer
    • Member
      698 point Member
    • Yovav
    • Member since 02-19-2003, 2:35 PM
    • Las Vegas
    • Posts 171
    10X N C U L8R
    Best Regards
    YovavG@GMail.com
Page 1 of 1 (3 items)