Sorry, the additional code should pass "false" instead of throwOnError.

        Type type=relativeAssembly.GetType(typeName, false, ignoreCase);
        if (type!=null) return type;
        foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) {
          type=assembly.GetType(typeName, false, ignoreCase);
          if (type!=null) return type;
        }
        if (throwOnError) throw new TypeLoadException("Type '"+typeName+"' cannot be found");
        else return null;

- Alexey.

Alexey N. Solofnenko wrote:
Hello,

I have tried the following code in SystemInfo.getTypeFromString() and it works well on my computer. Instead of looking for a class in just relativeAssembly, all loaded assemblies are searched for the class. Do you think log4net can be updated to do the same?

Sincerely,
  Alexey Solofnenko.


        public static Type GetTypeFromString(Assembly relativeAssembly, string typeName, bool throwOnError, bool ignoreCase)
        {
            // Check if the type name specifies the assembly name
            if(typeName.IndexOf(',') == -1)
            {
                //LogLog.Debug("SystemInfo: Loading type ["+typeName+"] from assembly ["+relativeAssembly.FullName+"]");
#if NETCF
                return relativeAssembly.GetType(typeName, throwOnError);
#else
                Type type=relativeAssembly.GetType(typeName, throwOnError, ignoreCase);
        if (type!=null) return type;
        foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) {
          type=assembly.GetType(typeName, false, ignoreCase);
          if (type!=null) return type;
        }
        if (throwOnError) throw new TypeLoadException("Type '"+typeName+"' cannot be found");
        else return null;
#endif
            }
            else
            {
                // Includes assembly name
                //LogLog.Debug("SystemInfo: Loading type ["+typeName+"] from global Type");
#if NETCF
                return Type.GetType(typeName, throwOnError);
#else
                return Type.GetType(typeName, throwOnError, ignoreCase);
#endif
            }
        }

Reply via email to