guryanovev / CrystalQuartz

pluggable UI for Quartz.NET
MIT License
1.01k stars 313 forks source link

Method 'TriggerFired' in type 'CrystalQuartz.Core.Quartz2.Quartz2SchedulerEventSource' from assembly 'CrystalQuartz.AspNetCore, #79

Open guazilalala opened 5 years ago

guazilalala commented 5 years ago

Unable to load one or more of the requested types. Method 'TriggerFired' in type 'CrystalQuartz.Core.Quartz2.Quartz2SchedulerEventSource' from assembly 'CrystalQuartz.AspNetCore, Version=6.8.1.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

public static Type[] GetAllTypes(this AppDomain @this, bool fromCache = true)
    {
        if (fromCache && (typeCache == null || !typeCache.Any()) || !fromCache)
        {
            typeCache = @this.GetExcutingAssemblies()
                .SelectMany(x =>
                {
                    try
                    {
                        return x.DefinedTypes.Select(t => t.AsType()); // Throw System.Reflection.ReflectionTypeLoadException
                    }
                    catch (ReflectionTypeLoadException ex)
                    {
                        return ex.Types.Where(t => t != null);
                    }
                }).ToArray();
        }

        return typeCache;
}
guryanovev commented 5 years ago

Please try to exclude CrystalQuartz assemblies from the scan like this:

@this.GetExcutingAssemblies().Where(x => !x.FullName.StartsWith("CrystalQuartz"))

In general it's a good practice to scan only your internal assemblies (unless you really need all the external classes):

assemblies.Where(x => x.FullName.StartsWith("MyRootAssemblyPrefix"))