0

我们有一个类型缓存系统,以避免在每次应用程序启动时搜索所有类型的所有插件程序集,但是当从 .NET 1.1 移动到 2.0+ 时,事件日志会记录一个致命的执行引擎错误 (6B3979C6) ( AppDomain.Load() 上的 80131506)

当且当 1. AppDomain 不是 AppDomain.CurrentDomain。2. 程序集不在可执行文件的目录中。

我们允许用户在特定于项目的目录中提供他们自己的程序集,因此我们无法解决 2。

我相信 1. 是需要的,因此我们可以在浏览类型后将 AppDomain 卸载到。

我不是此代码的所有者,但如果我没有提供足够的信息,我可以提出正确的问题。

此代码导致无法捕获的错误:

    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);
        }
    }
4

1 回答 1

0

这是由第三方许可库导致的,该库将错误代码注入到进程中。

于 2009-06-14T07:09:57.563 回答