surya syamala

surya syamala

  • NA
  • 22
  • 15.1k

Exception in c#

Mar 4 2013 6:04 AM
Hi,
Iam getting the exception as mentioned below. Can u pls solve this issue.

A first chance exception of type 'System.InvalidCastException' occurred in App9.exe
'App9.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Diagnostics.Debug\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Diagnostics.Debug.dll'
Step into: Stepping over method without symbols 'System.Exception.ToString'


Code:

 private void textloaded(object sender, RoutedEventArgs e)  //Added tyhis function to access textblock in datatemplate.
        {
            TextBlock tb = (TextBlock)sender;
            tb.Visibility = Visibility.Visible;   //exception at this line.
        } 
        void dispatcherTimer_Tick(object sender, object e)
         {
          
            DateTimeOffset time = DateTimeOffset.Now;
            TimeSpan span = time - lastTime;
            lastTime = time;
           
            timesTicked++;
            if (timesTicked == 10)
            {
                RoutedEventArgs routedEventArgs = new RoutedEventArgs();

                textloaded(sender, routedEventArgs);
              
             }    
                    
                if (timesTicked > timesToTick)
                { 
                    stopTime = time;
                  
                    dispatcherTimer.Stop();
                   
                    span = stopTime - startTime;
                   
                }
        }

Thank you,
syamala.

Answers (2)