random TypeLoadException

I am having real issues with a TypeLoadException that occurs generally randomly. I've been working on a .NETCF 2.0 app all day, debugging and generally being productive. All of a sudden, with no changes to the assemblies, I get a TypeLoadException on one of the types in one of my referenced assemblies. It's one of my own assemblies, and I checked the manifest and didn't notice anything untoward.

// Metadata version: v2.0.50727 .assembly extern mscorlib { .publickeytoken = (96 9D B8 05 3D 33 22 AC ) // ....=3". .ver 2:0:0:0 } .assembly extern retargetable System.Data { .publickeytoken = (96 9D B8 05 3D 33 22 AC ) // ....=3". .ver 2:0:0:0 } .assembly extern retargetable System.Xml { .publickeytoken = (96 9D B8 05 3D 33 22 AC ) // ....=3". .ver 2:0:0:0 } .assembly extern retargetable System.Web.Services { .publickeytoken = (96 9D B8 05 3D 33 22 AC ) // ....=3". .ver 2:0:0:0 } .assembly extern retargetable System.Windows.Forms { .publickeytoken = (96 9D B8 05 3D 33 22 AC ) // ....=3". .ver 2:0:0:0 } .assembly extern retargetable System { .publickeytoken = (96 9D B8 05 3D 33 22 AC ) // ....=3". .ver 2:0:0:0 } .assembly extern retargetable System.Drawing { .publickeytoken = (96 9D B8 05 3D 33 22 AC ) // ....=3". .ver 2:0:0:0 } .assembly extern OpenNETCF { .publickeytoken = (E6 0D BE A8 4B B4 31 B7 ) // ....K.1. .ver 2:0:0:0 } .assembly extern retargetable System.Data.SqlServerCe { .publickeytoken = (3B E2 35 DF 1C 8D 2A D3 ) // ;.5...*. .ver 3:0:3600:0 } .assembly extern OpenNETCF.Configuration { .publickeytoken = (E6 0D BE A8 4B B4 31 B7 ) // ....K.1. .ver 2:0:0:0 } .assembly extern OpenNETCF.Drawing { .publickeytoken = (E6 0D BE A8 4B B4 31 B7 ) // ....K.1. .ver 2:0:0:0 } .assembly extern retargetable System.Data.SqlClient { .publickeytoken = (3B E2 35 DF 1C 8D 2A D3 ) // ;.5...*. .ver 3:0:3600:0 }



Answer this question

random TypeLoadException

  • andreas s

    I meant, maybe one of the .NET assemblys is corrupt, which is why I suggested reinstalling the framework. In Visual Studio 2005 Team Suite Edition, when not in debug mode, the Debug menu is with all the other standard menus (between Build and Data).


  • kanna215

    Those "Missing Type" messages are clearly pretty bad--I'm going to look deeper on this end, but if you haven't already, could you try to uninstall/reinstall It looks like the installation could be messed up somehow (where "somehow" is yet to be defined...).

    If you've done this, try to extract mscorlib from the device and use "ildasm" to make sure it has all of the types it's complaining about defined. I can't imagine why it wouldn't, but if we can verify that they are defined in the assembly then we can start looking elsewhere for answers.

    Thanks,

    Ryan Chapman

    .NET Compact Framework


  • Pitchec0934

    A new wrinkle... The error only manifests itself when I'm trying to run the application through the debugger. If I just run the application on the device, I don't get any exceptions like that. Unfortunately, this is an unacceptable situation, since I am in active development. Also, this occurs when debugging against the WM5 emulator and another WM5 device.

    -Matthew


  • NeederOfVBHelp

    Hi Matthew--if you're still having this problem, it might help to turn on loader logging as described in Steven Pratschner's blog:

    http://blogs.msdn.com/stevenpr/archive/2005/02/28/381744.aspx

    This will often lead you directly to the answer for TypeLoadExceptions.

    Let me know if this helps...

    Thanks,

    Ryan Chapman

    .NET Compact Framework


  • xplosiv_1

    Are the TypeLoadExceptions stemming from your "ItemSecurityManager" type   Since generic types are loaded recursively, it's possible that declaring a generic collection of something that eventually includes an "ItemSecurityManager" could result the chain of Missing Type errors that we're seeing here.

    I can't think of a good reason why, but possibly your SharedInterfaces assembly is out of sync with your desktop version when you're running under the debugger--try to pry it off the device and crack it open with ildams to see if it has "ItemSecurityManager" in it.

    Cheers,

    Ryan Chapman

    .NET Compact Framework


  • PiGuy

    I've cleaned, warm-booted, and recompiled the solution several times, so I'm not sure on the corruption thing.  Where is that debug menu   Unfortunately, the error occurs before the debugger hits any breakpoints whatever, so I have no idea what's going on.  What kind of security issue would there be on the Compact Framework   I'm not sure that it's that anyway, since this app was working just fine and all of a sudden started generated this exception.  I don't think it's a memory issue, either, since my device has over 37MB of program memory and 44MB of storage memory, and the footprint of the application when it runs isn't but a couple megs after the CF loads.

    -Thanks, Matthew

     


  • I.You

    I am still getting this exception, and I enabled the Loader Logging feature and get the loader log, but the output does not make it immediately clear what the problem is.

    Here is the LoaderLog output:

    ========================================
    Process [\Program Files\AVMMobile\AVMMobile.exe]
    ProcessID [0xcf1766d2]
    Date [2006/11/20] (yyyy/mm/dd)
    Time [19:43:39] (hh:mm:ss)
    NETCF [2.0.6129.00]
    Platform [Windows CE v5.1.70 (PocketPC) WinCE5ARMV4I release V2\SP1 ARMV4I IJITv2]
    ========================================
    GAC: Updating GAC [0x0]
    GAC: Checking .gac files inside [\Windows\]
    GAC: Found [Microsoft .NET Compact Framework 1.0.GAC] .gac file.
    GAC: Found [Microsoft .NET CF 2.0.GAC] .gac file.
    GAC: Found [System.SR.2.0.ENU.gac] .gac file.
    GAC: Done with the file system check. Checking the registry.
    GAC: Found [Microsoft .NET CF 2.0.GAC] registry entry.
    GAC: Found [Microsoft .NET Compact Framework 1.0.GAC] registry entry.
    GAC: Done with the registry check. Let's compare.
    GAC: Entry [Microsoft .NET CF 2.0.GAC] is up to date.
    GAC: Entry [Microsoft .NET Compact Framework 1.0.GAC] is up to date.
    GAC: Entry [System.SR.2.0.ENU.gac] is about to be updated.
    GAC: Entry [System.SR.2.0.ENU.gac] is about to be cleaned up.
    GAC: GAC is up to date.
    Compatibility mode [2.0.0.0]
    Loading module [\Windows\GAC_mscorlib_v2_0_0_0_cneutral_1.dll]
    Loaded [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\Windows\GAC_mscorlib_v2_0_0_0_cneutral_1.dll]
    Loading module [\Program Files\AVMMobile\AVMMobile.exe]
    Trust verification passed. Module [\Program Files\AVMMobile\AVMMobile.exe], Trust [2], Proc [2].
    Loading module [\Program Files\AVMMobile\Slb.AvocetVM.Mobile.ClientObjects.dll]
    Trust verification passed. Module [\Program Files\AVMMobile\Slb.AvocetVM.Mobile.ClientObjects.dll], Trust [1], Proc [2].
    Failed to load [Slb.AvocetVM.Mobile.ClientObjects, Version=3.0.61116.826, Culture=neutral, PublicKeyToken=null] from GAC
    Loaded [Slb.AvocetVM.Mobile.ClientObjects, Version=3.0.61116.826, Culture=neutral, PublicKeyToken=null] from [\Program Files\AVMMobile\Slb.AvocetVM.Mobile.ClientObjects.dll]
    Policy file not present. [\Program Files\AVMMobile\AVMMobile.exe.config]
    Loading module [\Windows\GAC_System.Windows.Forms_v2_0_0_0_cneutral_1.dll]
    Loaded [System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\Windows\GAC_System.Windows.Forms_v2_0_0_0_cneutral_1.dll]
    Loading module [\Windows\GAC_System_v2_0_0_0_cneutral_1.dll]
    Loaded [System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\Windows\GAC_System_v2_0_0_0_cneutral_1.dll]
    Loading module [\Windows\GAC_System.Drawing_v2_0_0_0_cneutral_1.dll]
    Loaded [System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\Windows\GAC_System.Drawing_v2_0_0_0_cneutral_1.dll]
    Loading module [\Windows\GAC_System.Windows.Forms.DataGrid_v2_0_0_0_cneutral_1.dll]
    Loaded [System.Windows.Forms.DataGrid, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\Windows\GAC_System.Windows.Forms.DataGrid_v2_0_0_0_cneutral_1.dll]
    Loading module [\Windows\GAC_System.Xml_v2_0_0_0_cneutral_1.dll]
    Loaded [System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\Windows\GAC_System.Xml_v2_0_0_0_cneutral_1.dll]
    Loading module [\Program Files\AVMMobile\Slb.AvocetVM.Mobile.SharedInterfaces.dll]
    Trust verification passed. Module [\Program Files\AVMMobile\Slb.AvocetVM.Mobile.SharedInterfaces.dll], Trust [1], Proc [2].
    Failed to load [Slb.AvocetVM.Mobile.SharedInterfaces, Version=3.0.61116.826, Culture=neutral, PublicKeyToken=null] from GAC
    Loaded [Slb.AvocetVM.Mobile.SharedInterfaces, Version=3.0.61116.826, Culture=neutral, PublicKeyToken=null] from [\Program Files\AVMMobile\Slb.AvocetVM.Mobile.SharedInterfaces.dll]
    Loading module [\Windows\GAC_System.Web.Services_v2_0_0_0_cneutral_1.dll]
    Loaded [System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\Windows\GAC_System.Web.Services_v2_0_0_0_cneutral_1.dll]
    Missing Type. Class [System.Nullable`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Nullable`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Nullable`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [Slb.AvocetVM.ItemCore.ItemSecurity.ItemSecurityManager], Assembly [Slb.AvocetVM.Mobile.SharedInterfaces, Version=3.0.61116.826, Culture=neutral, PublicKeyToken=null].
    Loading module [\Windows\GAC_System.Data_v2_0_0_0_cneutral_1.dll]
    Loaded [System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\Windows\GAC_System.Data_v2_0_0_0_cneutral_1.dll]
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Globalization.CultureInfo], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Globalization.CompareOptions], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.IFormatProvider], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.StringComparer], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.WeakReference], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.BitArray], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.IList`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Collections.Generic.List`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [System.Nullable`1], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [Slb.AvocetVM.ItemCore.GraphDefinition], Assembly [Slb.AvocetVM.Mobile.SharedInterfaces, Version=3.0.61116.826, Culture=neutral, PublicKeyToken=null].
    Missing Type. Class [System.Collections.Generic.Dictionary`2], Assembly [mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC].
    Missing Type. Class [Slb.AvocetVM.Security.LoginResults], Assembly [Slb.AvocetVM.Mobile.SharedInterfaces, Version=3.0.61116.826, Culture=neutral, PublicKeyToken=null].
    ==================(end)=================

    All of the public key tokens look OK, and I have the .NETCF 2.0SP1 installed on both my workstation and device. I am unsure what to make of all the "Missing Type" exceptions with the System.Collections.Generic and System.Nullable, etc. types.

    Any thoughts

    -Matthew


  • Anant Badgujar

    And just to make it perfectly clear (to me anyway...), this is still only occurring while you're debugging You can run the identical binaries on the device without the debugger attached and the application works

    If so, I think we're going to need to see some sample code if you can come up with a simple repro, because frankly this one is stumping me...

    Ryan


  • Doug Marquardt

    Ilya Tumanov wrote:

    Is Slb.AvocetVM.Mobile.SharedInterfaces.dll delay signed by any chance You can verify that by running “sn –v <assembly>”.

    No. It is not signed at all.

    -Matthew


  • Fokus

    I completely hard-reset the device, then reinstalled the .NETCF, and the redeployed the application and _still_ get the TypeLoadException. This is getting _very_ frustrating.

    -Matthew


  • Howard B

    Is Slb.AvocetVM.Mobile.SharedInterfaces.dll delay signed by any chance You can verify that by running “sn –v <assembly>”.



  • CassieC

    Ryan Chapman wrote:

    Those "Missing Type" messages are clearly pretty bad--I'm going to look deeper on this end, but if you haven't already, could you try to uninstall/reinstall It looks like the installation could be messed up somehow (where "somehow" is yet to be defined...).

    If you've done this, try to extract mscorlib from the device and use "ildasm" to make sure it has all of the types it's complaining about defined. I can't imagine why it wouldn't, but if we can verify that they are defined in the assembly then we can start looking elsewhere for answers.

    Thanks,

    Ryan Chapman

    .NET Compact Framework

    I have done everything to this device that one can do: I've cold-booted it and installed the .NETCF2.0, then upgraded to the .NETCF2.0sp1. I've uninstalled the .NETCF2.0sp1 then reinstalled it. I just used ildasm on the \Windows\GAC_mscorlib_v2_0_0_0_cneutral_1.dll file (which is what's getting loaded according to the loader log), and all of the System.* types that are reported as missing are in fact there.

    Thanks,

    Matthew


  • llap444

    Ryan Chapman wrote:

    Are the TypeLoadExceptions stemming from your "ItemSecurityManager" type Since generic types are loaded recursively, it's possible that declaring a generic collection of something that eventually includes an "ItemSecurityManager" could result the chain of Missing Type errors that we're seeing here.

    I can't think of a good reason why, but possibly your SharedInterfaces assembly is out of sync with your desktop version when you're running under the debugger--try to pry it off the device and crack it open with ildams to see if it has "ItemSecurityManager" in it.

    Actually, the TypeLoadExceptions stem from the LoginResults type. I inspected the device version of the assembly using ildasm and all of the types that are reported to be missing all exist in that assembly. The assembly for the mobile device is a subset of the desktop version of that assembly, with some custom stub classes included to get it to compile.

    This is really frustrating for me. I completely wiped and rebuilt my machine to try to clear out any *** that might have existed and still no joy.

    Thanks for your help,

    Matthew


  • RussP

    Possibly a lack of memory or security issue, or perhaps the actual assembly is corrupt In the meantime, you could try disabling the Exception in the dubug menu.

    Debug > Exceptions... > Common Language Runtime Exceptions > System > System.TypeLoadException

    You should re-enable this as soon as you find a solution. I reccomend reinstalling .NET 2.0 (and/or compact) framework.


  • random TypeLoadException