Re: Casting Problem

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Scott Allen (bitmask_at_[nospam)
Date: 08/18/04


Date: Wed, 18 Aug 2004 09:51:30 -0400

Hi Carlo:

This does seem quite strange. I'm out of ideas on why it might behave
this way, unless there is some conversion operator or COM interop
going on behind the scences.

--s

On Tue, 17 Aug 2004 23:11:02 -0700, "Carlo Marchesoni"
<CarloMarchesoni@discussions.microsoft.com> wrote:

>Thank you for your hint Scott. I tried it and it drives me even more crazy,
>since in the debugger it works, but the same line "at runtime" fails.
>I put a breakpoint before the line, and inspected the Session variable:
>?System.Web.HttpContext.Current.Session["BackEnd"]
>{BackEnd}
> System.Object: {BackEnd}
> con: {com.Transoft.TCA.TCAConnection}
>
>looks okay, so I went ahead and assigned it to my private field, casting the
>session variable:
>this.backend = (BackEnd)System.Web.HttpContext.Current.Session["BackEnd"]
>{BackEnd}
> System.Object: {BackEnd}
> con: {com.Transoft.TCA.TCAConnection}
>
>and it works as well !!!
>But now comes the thing I don't understand: if I step to the next statement,
>which is exactly what I entered in the debugger window, it fails with the
>Specified cast is not valid
>message.
>

--
Scott
http://www.OdeToCode.com