AppDomain and ConfigurationFile's

After a bit of messing around when trying to make my own app domain I discovered that if you set the ConfigurationFile up to a place that doesn't exist you will get an error saying that it cannot load the assembly.  Which is a little confusing, since what it cannot actually load is the configuration file.  So if you make up an AppDomain make sure the config file exists.

Here is some code for making a simple AppDomain with the same permissions as the current AppDomain, if you fail to include the Evidence when making your AppDomain or do something different with this you will end up with an AppDomain that cannot load anything or something similar.

 

            perm = new PermissionSet(level.GetNamedPermissionSet("FullTrust"));
            perm.AddPermission(new ReflectionPermission(PermissionState.Unrestricted));
            perm.AddPermission(new SecurityPermission(PermissionState.Unrestricted));