locked
A first chance exception of type 'System.PlatformNotSupportedException' occurred in System.Core.dll RRS feed

  • Question

  • I'm learning Entity Framework. I'm testing in a Windows Forms application.

    I already have a SQL Server 2005 database. I have generated a model from this database.

     At form level in my startup form, I'm declaring an ObjectContext object:

    Protected context As TestEntities
    
    

    In the Load event for this form, I am calling the following Sub:

     Private Sub QueryEquipment()
    
      Using context
    
       Dim jobs = context.Jobs
    
       For Each job In jobs
    
        Debug.Print(String.Format("JobNumber: {0} WorkOrderNumber: {1}", job.JobNumber, job.WorkOrder.WorkOrderNumber))
    
       Next
    
      End Using
    
     End Sub
    
    

    As I step through the routine, when code reaches the 'For Each job in jobs' line, the following is printed in the immediate window: 

    Step into: Stepping over method without symbols 'System.Data.Objects.ObjectQuery<EntityFrameworkTest.Job>.System.Collections.Generic.IEnumerable<T>.GetEnumerator'
    A first chance exception of type 'System.PlatformNotSupportedException' occurred in System.Core.dll
    Step into: Stepping over method without symbols 'System.Data.Common.Internal.Materialization.Shaper<EntityFrameworkTest.Job>.SimpleEnumerator.MoveNext'
    Step into: Stepping over method without symbols 'System.Data.Common.Internal.Materialization.Shaper<EntityFrameworkTest.Job>.SimpleEnumerator.Current.get'

    There happens to be four jobs associated with WorkOrder in the database. As I continue stepping through the routine, I again see the same exception, this time occuring in the following property in EntityFrameworkTest.Designer.vb.

     Public Property WorkOrder() As WorkOrder
    
      Get
    
       Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of WorkOrder)("EntityFrameworkTestModel.FK_Job_WorkOrder", "WorkOrder").Value
    
      End Get
    
      Set
    
       CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of WorkOrder)("EntityFrameworkTestModel.FK_Job_WorkOrder", "WorkOrder").Value = value
    
      End Set
    
     End Property
    
    

    The exception is thrown when the code in the getter is encountered.

    At this point, the jobs found by the query are printed. If I run the application without stepping through it, the contents of the immediate window are:

    A first chance exception of type 'System.PlatformNotSupportedException' occurred in System.Core.dll
    A first chance exception of type 'System.PlatformNotSupportedException' occurred in System.Core.dll
    JobNumber: 00001 WorkOrderNumber: 989620003030
    JobNumber: 00002 WorkOrderNumber: 989620003030
    JobNumber: 00003 WorkOrderNumber: 989620003030
    JobNumber: 00004 WorkOrderNumber: 989620003031

    Can someone tell me what's going on? It is very frustrating to dive into a new and (supposedly) more mature technology and see exceptions thrown before I even gat past a simple query. Maybe I'm doing something wrong?

    Thanks.


    Sunday, August 7, 2011 4:34 PM

Answers

  • Regarding first change exception, here's a good article which talks about it. http://blogs.msdn.com/b/davidklinems/archive/2005/07/12/438061.aspx

    I enumerate some important point in this article, please check them.

    When an application is being debugged, the debugger gets notified whenever an exception is encountered  At this point, the application is suspended and the debugger decides how to handle the exception. The first pass through this mechanism is called a "first chance" exception. Depending on the debugger's configuration, it will either resume the application and pass the exception on or it will leave the application suspended and enter debug mode. If the application handles the exception, it continues to run normally.

    If the application does not handle the exception, the debugger is re-notified. This is known as a "second chance" exception. The debugger again suspends the application and determines how to handle this exception. Typically, debuggers are configured to stop on second chance (unhandled) exceptions and debug mode is entered, allowing you to debug.

    First chance exception messages most often do not mean there is a problem in the code. For applications / components which handle exceptions gracefully, first chance exception messages let the developer know that an exceptional situation was encountered and was handled.

    For code without exception handling, the debugger will receive a second chance exception notification and will stop with a unhandled exception.

    Thanks,

    Werewolf, 


    Just a newbie for everything.
    • Proposed as answer by Werewolfs Wednesday, August 10, 2011 3:03 AM
    • Marked as answer by vba-dev Thursday, August 11, 2011 3:03 PM
    Wednesday, August 10, 2011 3:03 AM

All replies

  • Regarding first change exception, here's a good article which talks about it. http://blogs.msdn.com/b/davidklinems/archive/2005/07/12/438061.aspx

    I enumerate some important point in this article, please check them.

    When an application is being debugged, the debugger gets notified whenever an exception is encountered  At this point, the application is suspended and the debugger decides how to handle the exception. The first pass through this mechanism is called a "first chance" exception. Depending on the debugger's configuration, it will either resume the application and pass the exception on or it will leave the application suspended and enter debug mode. If the application handles the exception, it continues to run normally.

    If the application does not handle the exception, the debugger is re-notified. This is known as a "second chance" exception. The debugger again suspends the application and determines how to handle this exception. Typically, debuggers are configured to stop on second chance (unhandled) exceptions and debug mode is entered, allowing you to debug.

    First chance exception messages most often do not mean there is a problem in the code. For applications / components which handle exceptions gracefully, first chance exception messages let the developer know that an exceptional situation was encountered and was handled.

    For code without exception handling, the debugger will receive a second chance exception notification and will stop with a unhandled exception.

    Thanks,

    Werewolf, 


    Just a newbie for everything.
    • Proposed as answer by Werewolfs Wednesday, August 10, 2011 3:03 AM
    • Marked as answer by vba-dev Thursday, August 11, 2011 3:03 PM
    Wednesday, August 10, 2011 3:03 AM
  • Thanks very much. I'll study the article.
    Thursday, August 11, 2011 3:03 PM