dotnet windows forms designtime:
Ok, this is a really wacky situation but I have this scenario:
1) An application project.
2) A library project with controls used by the application.
In the designer of one of the controls, what I want to do is enumerate
through all the classes in the application project and look for classes that
inherit from a class in the library project so that I can build a list of
them and display them to the user.
This code snippet works fine if I run it at run-time but not at design-time.
It seems like the application's assembly is not loaded in the AppDomain when
designing one of the Forms in the application:
--
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies) {
Type[] types = assembly.GetTypes();
foreach (Type type in types) {
if (type.IsSubclassOf(targetType))
MessageBox.Show(type.FullName);
}
}
--
None of the Assembly.GetXXX methods return the application's assembly
either. I did find that Assembly.Load will load it if I pass the name,
however I don't know the name unless I hardcode it and since other apps will
use the library assembly, I can't hardcode the name.
So my question is, while designing a Form in the application project, from a
Designer class in the referenced library project, how can I get the Types in
the application project so that I can enumerate through them?
Or, even if someone can tell me how to get the full name of the application
assembly from the library, that would enable me to use Assembly.Load.
Thanks in advance,
Bill