System.TypeLoadException

I'm getting a System.TypeLoadException when I attempt to run my app.  I do not get any errors when I compile the app.  The exception message is, "Type 'Utilities.ControlTools.Managers.BoundControlsManager`1' from assembly 'Utilities.Main, Version=1.0.1947.39274, Culture=neutral, PublicKeyToken=null' tried to override method 'OnAddingItem' but does not implement or inherit that method."  Notice that BoundControlsManager(Of T As BoundControl) implements generics and inherits from Utilities.Lists.BoundObjectsManager(Of T As IBoundObject) which inherits from Utilities.Lists.ListAdv(Of T) which inherits from System.Object.  Is this a known issue of v2.0 Beta 2 and are there any workarounds

Thanks for any help.
Lance


Answer this question

System.TypeLoadException

  • Abercrombie07

    Thank you for the idea, but what I discovered is that the issue arrises when a generic class is defined in one project and then used in another project.  Here is a sample:

    ' ********************************
    ' Put this code in Project1 (i.e., NOT the project that contains the main form.
    ' ********************************

    Public Class Class1(Of T)
      Public Overridable Function GetIt() As T
      End Function
      Public Overridable Sub SetIt(ByVal item As T)
      End Sub
      Public Overridable Sub ShowIt()
      End Sub
    End Class

    Public Class Class2(Of T)
      Inherits Class1(Of T)
    End Class

    ' ********************************
    ' Put this code in Project2 (i.e., the project that contains the main form.
    ' ********************************

    Public Class Class3(Of T)
      Inherits Project1.Class2(Of T)
      Public Overrides Function GetIt() As T
      End Function
      Public Overrides Sub SetIt(ByVal item As T)
      End Sub
      Public Overrides Sub ShowIt()
      End Sub
    End Class

    Public Class Form1
      Sub New()
        MyBase.New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Dim x As New Class3(Of Object)
      End Sub
    End Class

    Note that the exception does not occur if Class3 inherits from Project1.Class1 or if Class3 does not contain any overrides.  Also note that any one of the overrides in Class3 will cause the exception to occur.

    Please do not hesitate to let me know if you have any questions.

    Thanks,
    Lance


  • Freerider

    Believe it or not I think this is a bug we just fixed yesterday. This sounds extremely similar.  It should be fixed in our final shipping version. 

  • Daan van Schaijk

    It appears that when you are running your application you may be using different version of the assembly Utilities.Main.dll to the one that was used when your application was compiled.

  • System.TypeLoadException