TypeLoadException with BusinessListBase

TypeLoadException with BusinessListBase

Old forum URL: forums.lhotka.net/forums/t/1407.aspx


jwooley posted on Thursday, October 05, 2006

There appears to be a problem with the VS IDE/debugger when watching new BusinessListBase objects. Simply creating a new BLB, the debugger will internally report the following value for NewProjectResources and GetProjectResources: "Count = Exception of type: '{System.TypeLoadException}' occurred. "

This was previously identified in the following thread http://forums.lhotka.net/forums/thread/4748.aspx. Since the thread title refered to ActiveObjects, I'm not sure if Rocky noticed the issue at that time. I have confirmed it is an issue with PTracker 2.0.3 and 2.1 at this point.

To reproduce the issue, put a break point on the ProjectResources.NewProjectResources and watch what the debugger windows report. Note: If you call the .Count method on the collection, it returns the correct value and the WinTracker appears to work fine and ignores the "exception". Additionally, turning on all thrown exceptions, including TypeLoadException doesn't catch it, so I suspect the issue is something internal to the .Net framework which it is swallowing and the VS IDE is not reporting on.

I would be interested in others checking and confirming the behavior.

Jim Wooley
http://devauthority.com/blogs/jwooley

RockfordLhotka replied on Thursday, October 05, 2006

Can you try this with a normal BindingList<T> to see if it happens there? That'd help establish whether it is something in CSLA or just in .NET.

jwooley replied on Friday, October 06, 2006

I tried the below code and am not seeing the same behavior natively with the BindingList<T>. It may be something in CSLA. I'm concerned with the issue of the exception not being catchable.

 

Public Class GenericClass(Of T)

    Protected Sub New()

 

    End Sub

    Private _T As T

    Public Property Bar() As T

        Get

            Return _T

        End Get

        Set(ByVal value As T)

            _T = value

        End Set

    End Property

 

End Class

 

Public Class Class1

    Inherits GenericClass(Of String)

 

    Private _Ball As String = "Foo"

    Private Sub New()

        MyBase.New()

    End Sub

 

    Public Shared Function GetClass() As Class1

        Return New Class1

    End Function

 

    Public Property Ball() As String

        Get

            Return _Ball

        End Get

        Set(ByVal value As String)

            _Ball = value

        End Set

    End Property

End Class

 

Public Class ClassList

    Inherits System.ComponentModel.BindingList(Of Class1)

    Private Sub New()

 

    End Sub

 

    Protected Overrides Function AddNewCore() As Object

        Dim child As Class1 = Class1.GetClass

        Me.Add(child)

        Return child

    End Function

 

    Public Shared Function GetList() As ClassList

        Return New ClassList

    End Function

End Class

swegele replied on Wednesday, February 14, 2007

(Bumping) - While this isn't a critical issue because it just seems to be with QuickWatch and Watch ...the code actually works.

But I won't say it is a non-issue because I have become quite accustomed to my QuickWatch during development and debugging :-)

Copyright (c) Marimer LLC