Specified cast is not valid

  • Thread starter Thread starter Wayne Taylor
  • Start date Start date
W

Wayne Taylor

Hi All,

I'm receving this error can, does anyone know where I can find out more
detailed info?

Thanks in advance.

Wayne Taylor
 
Wayne Taylor said:
I'm receving this error can, does anyone know where I can find out more
detailed info?

Well, it means that you're trying to cast a reference to an unrelated
type, eg:

object o = "hello";

// Exception, because o isn't a reference to a stream.
Stream s = (Stream) o;

Does that help? If not, please give more information about when you're
getting it.
 
Wayne,
this is a very general error message. It basically
comes down to the fact that you are trying to convert one
datatype to another and it isn't valid.

example:
string s = null;
int i = s;

since integers are not reference types you can't store
null in it. Try debugging your application and step
through the code. You should be able to find exactly
where the error is occurring.

HTH
 
Back
Top