views:

300

answers:

1

We have a type caching system in place to avoid searching all plug-in assemblies for all types each time our application starts up, but when moving from .NET 1.1 to 2.0+, the Event Log records a Fatal Execution Engine Error (6B3979C6) (80131506) on the AppDomain.Load()

If and only if 1. the AppDomain is NOT AppDomain.CurrentDomain. 2. The assembly is not in the executable's directory.

We allow users to provide their own assemblies in project-specific directories, so we can't work around 2.

I believe 1. is wanted so we can unload the AppDomain to after skimming for types.

I'm not the owner of this code, but I can ask the right questions if I haven't provided enough information.

This code causes the uncatchable error:

    private static void AddAssembly( System.AppDomain appDom, Manifest manifest, string filenameWithoutExtension )
 {
  try
  {
            // Test that the assembly can be loaded...
            System.Reflection.Assembly.ReflectionOnlyLoad(filenameWithoutExtension);

   System.Reflection.Assembly assem = appDom.Load( filenameWithoutExtension );
   ArrayList attributes = new ArrayList();
   // System.Reflection.Assembly assem = System.Reflection.Assembly.LoadFrom(path+"\\"+file.Name);
   object[] attribs = assem.GetCustomAttributes( typeof(PlugInAttribute), false );
   if ( attribs.Length > 0 )
   {
    attribs = assem.GetCustomAttributes( false );
    foreach ( Attribute attr in attribs )
    {
     object[] attrAttrs = attr.GetType().GetCustomAttributes(typeof(PlugInAttribute), false );
     if ( attrAttrs.Length > 0 ) 
     {
      attributes.Add(attr.GetType().ToString());
      break;
     }
    }
   }
   if ( attribs.Length > 0 || attributes.Count > 0 )
   {
    Assembly assy = new Assembly( manifest );
    manifest.Assemblies.Add(assy);
    assy.Name = filenameWithoutExtension;
    assy.Version = AssemblyName.GetAssemblyName( System.IO.Path.Combine( manifest.Path, filenameWithoutExtension + ".dll") ).Version.ToString();
    assy.Attributes = (ArrayList)attributes.Clone();
    System.Type[] types = assem.GetTypes();
    foreach (System.Type type in types )
     if ( !type.IsNestedPrivate && !type.IsNestedPublic
      && !type.IsNestedAssembly  )
      assy.AddType( type );
   }
  }
  catch ( Exception ex )
  {
   System.Diagnostics.Trace.WriteLine( "Manifest.AddAssembly Exception: " + ex.Message );

   Manager.WriteException(ex);
  }
 }
A: 

This was caused by a third-party licensing library which injected buggy code into the process.

Cat