i am developing a application to experiment with genetic programming. As of now, the application is able to compile a model of source classes and wire events and methods according to the configuration stored in the model. Also, the application can mutate and rearrange the model in order to test alternative options.
The idea is to compile and run mutations of the models in secondary appdomains, one for each model.
This all works beautifull, the code gets compiled, the model is mutated the resulting population is executed, and none of the dynamic assemblies get loaded in the primary appdomain.
There is a catch however, one which i have no solution for at the moment.
When a user decides to write a piece of code, he can introduce code with possible faults. If such a piece of code executes on the main thread, the exception can be handled and processed safely. Not a problem there.
However when the user decides to introduce faulty code and execute it on a new thread (using classes available in the System.Threading namespace) the exception cannot be handled in any way.
This means that the AppDomain.UnhandledException event gets raised in the primary AppDomain, and the managing application (the experiment) terminates.
If i read the information regarding AppDomains and Threading correctl
View Complete Post