Dear ladies and sirs.
My question is simple. For unit test purposes, I need a statically compiled type deriving from the Exception type, which is known in one AppDomain, but unknown in another.
A straightforward solution would be:
- To create a subfolder under the directory of the application executable.
- Place there an assembly with some Exception derived type.
- Update the app.config file, adding this folder to the probing path.
- Create a new AppDomain, but with a slightly different app.config - without the element.
Now, the main AppDomain can load the type easily, because its location is in the probing path, but the second AppDomain cannot - mission accomplished.
But this method requires:
- An additional folder
- A dummy assembly
- A dummy app config file
I am wondering if I can achieve my goal simpler, but without Reflection.Emit.
Thanks.
EDIT:
Any Exception derived type will do.
Motivation:
We have a distributed application, consisting of clients, the server and agents. There are assemblies found exclusively on agents and there are some found exclusively on the server. Both the server and agents can be extended after being deployed with new features. The thing is that it is possible that some action will fail with an exception, which type is unknown on the receiving end. I am developing a facility to cope with this situation and wish to unit test it now. For that I need to simulate a situation where an exception raised on a remote site is of a type unknown on the receiving end.