I need to scan a directory full of .net assemblies and list all Form
subclasses found in a grid. This part is easy using reflection.
I then need to allow the user to double click and modally display the form.
Obviously I wouldn't expect anything to actually work; I just want it to be
visible. Just like what Visual Studio does when you design a form.
Unfortunately I cannot guarantee that the forms have default parameter-less
constructors and even if they did, I cannot guarantee that those
constructors could be successfully invoked (could have some static
dependencies, etc). So I can't simply instantiate them.
Since the forms have been built using Visual Studio, they should all have an
InitializeComponent method. What I really need to do is only invoke this.
Is there an easy way to do this?
If it was possible to create an AssemblyBuilder from an already compiled
Assembly, then I could just add the parameter-less constructor (or remove
the IL from an existing one) and disassociate all the event handlers.
I'm thinking that I need to create a new in-memory form subclass and
dynamically transfer the InitializeComponent IL from one to the other. How
hard would this be? I know that the assemblies have not been obfuscated.
Nathan