title: Asp.net Exception has been thrown by the target of an invocation
body: <p>I get the error message below when i try to run this code :</p>
  
  <pre><code>Protected Sub gv_PageIndexChanging(sender As Object, e As GridViewPageEventArgs)
          Try
              If Not Session("Data") Is Nothing Then
  
                  gv.DataSource = CType(Session("Data"), DataTable)
                  gv.PageIndex = e.NewPageIndex
                  gv.DataBind()
  
              End If
  
          Catch ex As Exception 
          End Try
      End Sub
  </code></pre>
  
  <p>Error :</p>
  
  <pre><code>Exception has been thrown by the target of an invocation.
     at System.RuntimeMethodHandle.SerializationInvoke(IRuntimeMethodInfo method, Object target, SerializationInfo info, StreamingContext&amp; context)
     at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
     at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
     at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
     at System.Runtime.Serialization.ObjectManager.DoFixups()
     at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
     at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
     at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
     at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck)
     at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)
     at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
     at System.Web.Util.AltSerialization.ReadValueFromStream(BinaryReader reader)
     at System.Web.SessionState.SessionStateItemCollection.ReadValueFromStreamWithAssert()
     at System.Web.SessionState.SessionStateItemCollection.DeserializeItem(String name, Boolean check)
     at System.Web.SessionState.SessionStateItemCollection.get_Item(String name)
     at System.Web.SessionState.HttpSessionStateContainer.get_Item(String name)
     at System.Web.SessionState.HttpSessionState.get_Item(String name)
     at gv_PageIndexChanging(Object sender, GridViewPageEventArgs e)
  </code></pre>
  
  <p>I tried to google for the solution but i never had any luck. Please help?</p>