lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1099565 - /incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
Date Wed, 04 May 2011 19:25:15 GMT
Author: digy
Date: Wed May  4 19:25:15 2011
New Revision: 1099565

URL: http://svn.apache.org/viewvc?rev=1099565&view=rev
Log:
[LUCENENET-412] added AppDomain.Unload to make NUnit release the reference to Lucene.Net.Test.dll

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs?rev=1099565&r1=1099564&r2=1099565&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/PartiallyTrustedAppDomain.cs
Wed May  4 19:25:15 2011
@@ -41,6 +41,7 @@ namespace Lucene.Net.Test
         /// <param name="methodArgs">method's parameters</param>
         public static object Run(Type clazz, string methodName, object[] constructorArgs,
object[] methodArgs)
         {
+            AppDomain appDomain = null;
             try
             {
                 AppDomainSetup setup = new AppDomainSetup { ApplicationBase = Environment.CurrentDirectory
};
@@ -48,10 +49,10 @@ namespace Lucene.Net.Test
                 PermissionSet permissions = new PermissionSet(null);
                 permissions.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
                 permissions.AddPermission(new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess));
-                permissions.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess,
TEMPDIR ));
+                permissions.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess,
TEMPDIR));
+
+                appDomain = AppDomain.CreateDomain("PartiallyTrustedAppDomain", null, setup,
permissions);
 
-                AppDomain appDomain = AppDomain.CreateDomain("PartiallyTrustedAppDomain",
null, setup, permissions);
-                                
                 object obj = appDomain.CreateInstanceAndUnwrap(
                     clazz.Assembly.FullName,
                     clazz.FullName,
@@ -61,31 +62,28 @@ namespace Lucene.Net.Test
                     constructorArgs,
                     System.Globalization.CultureInfo.CurrentCulture,
                     null);
-                
-                object ret =  clazz.InvokeMember(
-                    methodName, 
+
+                object ret = clazz.InvokeMember(
+                    methodName,
                     BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public
| BindingFlags.NonPublic,
-                    null, 
-                    obj, 
+                    null,
+                    obj,
                     methodArgs);
+
                 return ret;
             }
-            catch (TypeLoadException tlex)
-            {
-                throw tlex;
-            }
             catch (TargetInvocationException tiex)
             {
                 throw tiex.InnerException;
             }
-            catch (SecurityException secex)
-            {
-                throw secex;
-            }
             catch (Exception ex)
             {
                 throw ex;
             }
+            finally
+            {
+                if(appDomain!=null) AppDomain.Unload(appDomain);
+            }
         }
     }
 }



Mime
View raw message