Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1981

ReflectionTypeLoadException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.8.2
    • 1.9.0
    • csharp
    • None
    • C#: Catch exceptions loading types from other assemblies.

    Description

      In the ObjectCreator the call to FindType(name, throwError) can throw a ReflectionTypeLoadException during the call to assembly.GetTypes() if any of the types are not able to load, MSDN link below for ref. This effectively kills the entire deserialization process. I put in a simple workaround to just continue if this happens. In my particular case it was trying to load types from a devexpress test runner dll.

      https://msdn.microsoft.com/en-us/library/system.reflection.assembly.gettypes(v=vs.110).aspx

      private Type FindType(string name,bool throwError)
      {
      //other code
      foreach (Assembly assembly in assemblies)
      {
      // Fix for Mono 3.0.10
      if (assembly.FullName.StartsWith("MonoDevelop.NUnit"))
      continue;

      /Added catch in case assembly contains unloadable types/
      try

      { types = assembly.GetTypes(); }

      catch (ReflectionTypeLoadException ex)

      { continue; }

      //other code
      }

      Attachments

        Issue Links

          Activity

            People

              blachniet Brian Lachniet
              JSteward Josh Steward
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: