Alright, I've looked into this some more.
Is LLBL still using this code to look through assemblies? The .Net Reflector thinks so.
/// <summary>
/// Processes the assembly for type converters.
/// </summary>
/// <param name="toProcess">To process.</param>
/// <param name="toFill">To fill.</param>
internal static void ProcessAssemblyForTypeConverters(Assembly toProcess, Hashtable toFill)
{
Type[] types = toProcess.GetTypes();
foreach(Type currentType in types)
{
if(currentType.IsSubclassOf(typeof(TypeConverter)) && !currentType.IsAbstract)
{
// found a typeConverter type
TypeConverter converter = (TypeConverter)toProcess.CreateInstance(currentType.FullName);
if(converter==null)
{
continue;
}
TypeConverterDefinition converterDefinition = new TypeConverterDefinition();
converterDefinition.AssemblyName = toProcess.FullName;
converterDefinition.ConverterInstance = converter;
converterDefinition.TypeFullName = currentType.FullName;
// get description
object[] attributes = currentType.GetCustomAttributes(typeof(DescriptionAttribute), true);
if(attributes.Length>0)
{
converterDefinition.Description = ((DescriptionAttribute)attributes[0]).Description;
}
toFill.Add(currentType.FullName, converterDefinition);
}
}
}
I created a unit test with this code which pulls the type converter successfully even when it's in my library. I then put that same DLL into the type converters directory and it doesn't show anything in the designer.
I moved the type converter and this type off into its own project and now LLBL's fine with it all. Seems like there might be some type it's finding in my library that it dislikes and throws an error on, which then stops all the processing. Specifically, the code has a problem when a class is a TypeConverter, but doesn't allow an instance to be created directly with CreateInstance.
I found for example that if it went to probe some of the system DLLs, it'd throw a method missing exception when it tries to instantiate an instance to determine type at the toProcess.CreateInstance line (which in my unit test was line 49). If you're curious, here's a stack trace:
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName)
at [My Unit Test]:line 49
Might be worth wrapping that particular line with a try {} catch { continue; } so that even if it doesn't like a particular type, it doesn't give up and stop looking entirely. I think that'd fix the problem I'm having with the designer when it's in the library.
But for the moment I've worked around the issue by creating a separate DLL. Thanks again for all your help so far.