Example #1
0
        static APIWrapper()
        {
            _domain = AppDomain.CreateDomain("OPEN_TERRARIA_API_WRAPPER", null /*AppDomain.CurrentDomain.Evidence*/, new AppDomainSetup()
                {
                    //ShadowCopyFiles = "false",
                    ApplicationBase = Environment.CurrentDirectory/*, Commented out as OSX does not have this?
                    AppDomainManagerAssembly = String.Empty*/
                });

            var type = typeof(Proxy);
            foreach (var file in new string[] { "Patcher.exe", "OTA.dll" })
            {
                if (!System.IO.File.Exists(file))
                {
                    var bin = System.IO.Path.Combine(Environment.CurrentDirectory, "bin", "x86", "Debug", file);
                    if (System.IO.File.Exists(bin))
                    {
                        System.IO.File.Copy(bin, file);
                        Console.WriteLine("Copied: " + file);
                    }
                }
            }
            var plugin = _domain.CreateInstance(type.Assembly.FullName, type.FullName);
            _api = plugin.Unwrap() as Proxy;

            _api.Load(System.IO.Path.Combine(Environment.CurrentDirectory, "OTA.dll"));
        }
Example #2
0
 public static ObjectHandle CreateInstance(AppDomain domain, string assemblyName, string typeName)
 {
     if (domain == null)
     {
         throw new ArgumentNullException("domain");
     }
     return(domain.CreateInstance(assemblyName, typeName));
 }
		protected IWindsorContainer CreateRemoteContainer(AppDomain domain, String configFile)
		{
			ObjectHandle handle = domain.CreateInstance( 
				typeof(WindsorContainer).Assembly.FullName, 
				typeof(WindsorContainer).FullName, false, BindingFlags.Instance|BindingFlags.Public, null, 
				new object[] { configFile }, 
				CultureInfo.InvariantCulture, null, null );

			return (IWindsorContainer) handle.Unwrap();
		}
Example #4
0
 public static ObjectHandle CreateInstance(AppDomain domain, string assemblyName, string typeName,
                                           bool ignoreCase, BindingFlags bindingAttr, Binder binder,
                                           object [] args, CultureInfo culture,
                                           object [] activationAttributes)
 {
     if (domain == null)
     {
         throw new ArgumentNullException("domain");
     }
     return(domain.CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes));
 }
		protected IWindsorContainer GetRemoteContainer(AppDomain domain, String configFile)
		{
			ObjectHandle handle = domain.CreateInstance( 
				typeof(ContainerPlaceHolder).Assembly.FullName, 
				typeof(ContainerPlaceHolder).FullName, false, BindingFlags.Instance|BindingFlags.Public, null, 
				new object[] { configFile }, 
				CultureInfo.InvariantCulture, null, null );

			ContainerPlaceHolder holder = handle.Unwrap() as ContainerPlaceHolder;

			return holder.Container;
		}
Example #6
0
        internal static IAssembly LoadAssembly(string path, AppDomain domain)
        {
            if (domain != AppDomain.CurrentDomain) {
                var crossDomainAssembly = domain.CreateInstance<RemoteAssembly>();
                crossDomainAssembly.Load(path);

                return crossDomainAssembly;
            }

            var assembly = new RemoteAssembly();
            assembly.Load(path);
            return assembly;
        }
        static APIWrapper()
        {
            //_domain = AppDomain.CreateDomain("TDSM_API_WRAPPER", AppDomain.CurrentDomain.Evidence, new AppDomainSetup()
            //{
            //    //ShadowCopyFiles = "false",
            //    ApplicationBase = Environment.CurrentDirectory
            //});
            _domain = AppDomain.CreateDomain("OPEN_TERRARIA_API_WRAPPER", null /*AppDomain.CurrentDomain.Evidence*/, new AppDomainSetup()
                {
                    //ShadowCopyFiles = "false",
                    ApplicationBase = Environment.CurrentDirectory/*, Commented out as OSX does not have this?
                AppDomainManagerAssembly = String.Empty*/
                });

            //Console.WriteLine("Domain: " + ((_domain == null) ? "null" : "not null"));

            //_domain.AssemblyResolve += (s, a) =>
            //{
            //    try
            //    {
            //        //return Assembly.LoadFrom(Path.Combine(Globals.PluginPath, a.Name + ".dll"));
            //    }
            //    catch { }
            //    return null;
            //};

            var type = typeof(Proxy);
            foreach (var file in new string[] { "Patcher.exe", "OTA.dll" })
            {
                if (!System.IO.File.Exists(file))
                {
                    var bin = System.IO.Path.Combine(Environment.CurrentDirectory, "bin", "x86", "Debug", file);
                    if (System.IO.File.Exists(bin))
                    {
                        System.IO.File.Copy(bin, file);
                        Console.WriteLine("Copied: " + file);
                    }
                }
            }
            var plugin = _domain.CreateInstance(type.Assembly.FullName, type.FullName);
            //            var r = plugin.CreateObjRef(typeof(MarshalByRefObject));
            ////var p = r.GetRealObject(new System.Runtime.Serialization.StreamingContext( System.Runtime.Serialization.StreamingContextStates.CrossAppDomain));
            _api = plugin.Unwrap() as Proxy;

            _api.Load(System.IO.Path.Combine(Environment.CurrentDirectory, "OTA.dll"));

            //var has = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GetName().Name == "TDSM.API").Count() > 0;
            //var asm = _domain.GetAssemblies();
        }
        /// <summary>
        /// Factory method used to create a DomainAgent in an AppDomain.
        /// </summary>
        /// <param name="targetDomain">The domain in which to create the agent</param>
        /// <param name="traceLevel">The level of internal tracing to use</param>
        /// <returns>A proxy for the DomainAgent in the other domain</returns>
        static public DomainAgent CreateInstance(AppDomain targetDomain)
        {
#if CLR_2_0 || CLR_4_0
            System.Runtime.Remoting.ObjectHandle oh = Activator.CreateInstance(
                targetDomain,
#else
			System.Runtime.Remoting.ObjectHandle oh = targetDomain.CreateInstance(
#endif
 Assembly.GetExecutingAssembly().FullName,
                typeof(DomainAgent).FullName,
                false, BindingFlags.Default, null, null, null, null, null);

            object obj = oh.Unwrap();
            return (DomainAgent)obj;
        }
Example #9
0
        /// <summary>
        /// Returns a RemoteTestRunner in the target domain. This method
        /// is used in the domain that wants to get a reference to 
        /// a RemoteTestRunnner and not in the test domain itself.
        /// </summary>
        /// <param name="targetDomain">AppDomain in which to create the runner</param>
        /// <param name="ID">Id for the new runner to use</param>
        /// <returns></returns>
        public static RemoteTestRunner CreateInstance(AppDomain targetDomain, int ID)
        {
            #if NET_2_0
            System.Runtime.Remoting.ObjectHandle oh = Activator.CreateInstance(
                targetDomain,
            #else
            System.Runtime.Remoting.ObjectHandle oh = targetDomain.CreateInstance(
            #endif
                Assembly.GetExecutingAssembly().FullName,
                typeof(RemoteTestRunner).FullName,
                false, BindingFlags.Default, null, new object[] { ID }, null, null, null);

            object obj = oh.Unwrap();
            return (RemoteTestRunner)obj;
        }
Example #10
0
        static object InstantiateQA(AppDomain appDomain, Binder binder, CultureInfo cultureInfo, string MyName, string UName, int Id, string netP2pUri, string httpUri)
        {
            try
            {

                object instance = appDomain.CreateInstance(
                   "QA.Presentation",
                   "QA.Presentation.QADummy",
                   false,
                   BindingFlags.Default,
                   binder,
                   new object[] { MyName, UName, Id, netP2pUri, httpUri },
                   cultureInfo,
                   null,
                   null
                );
                return instance;
            }
            catch (Exception exp)
            {
                return null;
            }
        }
 static object InstantiateDecimal(AppDomain appDomain, Binder binder, CultureInfo cultureInfo, string UName, string P2PUri)
 {
     try
     {
         object instance = appDomain.CreateInstance(
            "ImageSharing.Presentation",
            "ImageSharing.Presentation.P2PImageSharingClient",
            false,
            BindingFlags.Default,
            binder,
            new object[] { UName, P2PUri },
            cultureInfo,
            null,
            null
         );
         return instance;
     }
     catch (Exception exp)
     {
         VMuktiHelper.ExceptionHandler(exp, "InstantiateDecimal", "P2PImageSharingDummyClient.cs");
         return null;
     }
 }
Example #12
0
        //**************************************************************
        // InitializeKeyCheck()
        //**************************************************************
        public void InitializeKeyCheck()
        {
            //Clear any previous app domain
            UnInitializeKeyCheck();

            AD = AppDomain.CreateDomain("KeyValidatorDomain");

            BindingFlags flags = (BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance);

            ObjectHandle objh = AD.CreateInstance( "AppUpdater", "Microsoft.Samples.AppUpdater.KeyValidator", false,
                               flags, null, null, null, null, null);

            // Unwrap the object
            Object obj = objh.Unwrap();

            // Cast to the actual type
            Validator = (KeyValidator)obj;

            KeyList = GetKeyList(AppUrl.TrimEnd(new char[] {'/'}) + "/" + KEYFILENAME);
        }
		/// <summary>
		/// Initialize the AppDomain and load the types of the dll
		/// </summary>
		/// <returns>the types of the dll</returns>
		public string[] LoadTypes()
		{

			string environmentPath = Environment.CurrentDirectory;
			string cachePath = Path.Combine(environmentPath,"__cache");

			PermissionSet permissionSet = new PermissionSet(PermissionState.Unrestricted);
			AppDomainSetup appDomainSetup = new AppDomainSetup
			                          	{
											ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
			                          		ShadowCopyFiles = "true",
			                          		CachePath = cachePath
			                          	};
			_testsDomain = AppDomain.CreateDomain("TestDomain", null, appDomainSetup, permissionSet);

			try
			{
                ITypesLoaderFactory typesLoaderFactory = (ITypesLoaderFactory)_testsDomain.CreateInstance(Assembly.GetExecutingAssembly().FullName, "RegTesting.Tests.Core.TypesLoaderFactory").Unwrap();
				object[] constructArgs = new object[] {};
                ITypesLoader typesLoader = typesLoaderFactory.Create(Assembly.GetExecutingAssembly().FullName, "RegTesting.Tests.Core.TypesLoader", constructArgs);
				Types = typesLoader.GetTypes(_testsFile);
				foreach (string type in Types)
				{
					if (type.StartsWith("ERROR:"))
					{
						Console.WriteLine(type);
					}
				}
				return Types;
			}
			catch (NullReferenceException)
			{
				//No types found for this branch
				return new string[0];
			}
			catch (ReflectionTypeLoadException reflectionTypeLoadException)
			{
				StringBuilder stringBuilder = new StringBuilder();
				foreach (Exception exSub in reflectionTypeLoadException.LoaderExceptions)
				{
					stringBuilder.AppendLine(exSub.Message);
					if (exSub is FileNotFoundException)
					{
						FileNotFoundException fileNotFoundException = exSub as FileNotFoundException;
						if (!string.IsNullOrEmpty(fileNotFoundException.FusionLog))
						{
							stringBuilder.AppendLine("Fusion Log:");
							stringBuilder.AppendLine(fileNotFoundException.FusionLog);
						}
					}
					stringBuilder.AppendLine();
				}
				string errorMessage = stringBuilder.ToString();
				Console.WriteLine(errorMessage);
				//Display or log the error based on your application.
				return new string[0];
			}
			catch (Exception exception)
			{
				Console.WriteLine(exception.ToString());
				//No types found for this branch
				return new string[0];
			}
		}
Example #14
0
 public static Sandbox CreateInstance(ref AppDomain sandbox)
 {
     sandbox = GetSandbox();
     return (Sandbox)sandbox.CreateInstance(Assembly.GetExecutingAssembly().FullName, typeof(Sandbox).FullName).Unwrap();
 }
Example #15
0
 public void Start()
 {
     _Domain = AppDomain.CreateDomain(_Setup.ApplicationName, null, _Setup);
     // Construct the target class, it must take over from there.
     _RemoteType = _Domain.CreateInstance(_TypeInfo[1], _TypeInfo[0]);
 }
		private static void InitConfigInNewAppDomain (AppDomain appDomain)
		{
			Type t = typeof (ConfigInitHelper);
			ObjectHandle o = appDomain.CreateInstance (t.Assembly.FullName, t.FullName);
			ConfigInitHelper helper = (ConfigInitHelper) o.Unwrap();
			helper.InitConfig ();
		}
        public AppInvokeEntryPointResult FindForm(AppDomain ad, string assemblyFile, string configFile)
        {
            //IAppInvokeEntryPoint result = null;
            AppInvokeEntryPointResult result = new AppInvokeEntryPointResult();

            try
            {
                // Load the primary assembly here
                Assembly asmEntryPoint = Assembly.LoadFrom(assemblyFile);

                // other assemblies
                Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();

                // entry point
                if (asmEntryPoint.EntryPoint == null)
                {
                    // find the entry point assembly
                    foreach (Assembly asm in asms)
                    {
                        if (asm.EntryPoint != null)
                        {
                            asmEntryPoint = asm;
                            break;
                        }
                    }
                }

                // Load all the assemblies                
                IDictionary<string, string> loadedAssemblies = result.LoadedAssemblies;
                foreach (Assembly asm in asms)
                {
                    string fullName = asm.FullName;
                    if (!loadedAssemblies.ContainsKey(fullName))
                    {
                        loadedAssemblies.Add(fullName, asm.Location);
                    }

                    foreach (var asmRef in asm.GetReferencedAssemblies())
                    {
                        fullName = asmRef.FullName;

                        if (!loadedAssemblies.ContainsKey(fullName))
                        {
                            Assembly asm2 = ad.Load(asmRef);
                            loadedAssemblies.Add(fullName, asm2.Location);
                        }
                    }
                }

                // find the entry point class implements our interface
                Type typeEntryPoint = asmEntryPoint.EntryPoint.DeclaringType;
                if (typeof(IAppInvokeEntryPoint).IsAssignableFrom(typeEntryPoint))
                {
                    AssemblyName asm = AssemblyName.GetAssemblyName(assemblyFile);
                    //result = ad.CreateInstanceAndUnwrap(asm.FullName, typeEntryPoint.FullName) as IAppInvokeEntryPoint;
                    result.AssemblyName = asm.FullName;
                    result.TypeName = typeEntryPoint.FullName;
                    result.Instance = ad.CreateInstance(asm.FullName, typeEntryPoint.FullName);
                }
            }
            catch (Exception ex)
            {
                ExceptionManagement.ExceptionManager.Publish(ex);
            }

            return result;
        }
 static object InstantiateDecimal(AppDomain appDomain, Binder binder, CultureInfo cultureInfo,string UName, string P2PUri)
 {
     try
     {
         object instance = appDomain.CreateInstance(
            "Video.Presentation",
            "Video.Presentation.P2PVideoClient",
            false,
            BindingFlags.Default,
            binder,
            new object[] {UName,P2PUri },
            cultureInfo,
            null,
            null
         );
         return instance;
     }
     catch (Exception exp)
     {
         exp.Data.Add("My Key", "InstantiateDecimal()--:--P2PVideoDummyClient.cs--:--" + exp.Message + " :--:--");
         //ClsException.LogError(exp);
         //ClsException.WriteToErrorLogFile(exp);
         System.Text.StringBuilder sb = new StringBuilder();
         sb.AppendLine(exp.Message);
         sb.AppendLine();
         sb.AppendLine("StackTrace : " + exp.StackTrace);
         sb.AppendLine();
         sb.AppendLine("Location : " + exp.Data["My Key"].ToString());
         sb.AppendLine();
         sb1 = CreateTressInfo();
         sb.Append(sb1.ToString());
         VMuktiAPI.ClsLogging.WriteToTresslog(sb);
         return null;
     }
 }   
Example #19
0
        private RemoteTestRunner CreateTestRunner(AppDomain domain)
        {
            ObjectHandle oh;
            Type rtrType = typeof(RemoteTestRunner);

            #if NET_4_0
            oh = domain.CreateInstance(
                rtrType.Assembly.FullName,
                rtrType.FullName,
                false,
                BindingFlags.Public | BindingFlags.Instance,
                null,
                null,
                CultureInfo.InvariantCulture,
                null);
            #else
            oh = domain.CreateInstance(
                rtrType.Assembly.FullName,
                rtrType.FullName,
                false,
                BindingFlags.Public | BindingFlags.Instance,
                null,
                null,
                CultureInfo.InvariantCulture,
                null,
                AppDomain.CurrentDomain.Evidence);
            #endif
            return (RemoteTestRunner) oh.Unwrap();
        }
Example #20
0
        static object InstantiateDecimal(AppDomain appDomain, Binder binder, CultureInfo cultureInfo, string MyName, string UName, int Id, string netP2pUri, string httpUri)
        {
            try
            {

                object instance = appDomain.CreateInstance(
                   "wb.Presentation",
                   "wb.Presentation.WhiteboardDummy",
                   false,
                   BindingFlags.Default,
                   binder,
                   new object[] { MyName, UName, Id, netP2pUri, httpUri },
                   cultureInfo,
                   null,
                   null
                );
                return instance;
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "InstantiateDecimal()", "DummyClient.cs");

                return null;
            }
        }
Example #21
0
        public void CompilePlugins(PermissionSet pluginSandboxPermissions, List<String> ignoredPluginClassNames = null) {
            try {

                if (File.Exists(Path.Combine(this.PluginBaseDirectory, "PluginCache.xml")) == true) {
                    WritePluginConsole("Loading plugin cache..");

                    try {
                        this.PluginCache = XDocument.Load(Path.Combine(this.PluginBaseDirectory, "PluginCache.xml")).Root.FromXElement<PluginCache>();
                    }
                    catch (Exception e) {
                        WritePluginConsole("Error loading plugin cache: {0}", e.Message);
                    }
                }

                // Recover from exceptions or logic errors if the document parsed correctly, but didn't deserialize correctly.
                if (this.PluginCache == null) {
                    this.PluginCache = new PluginCache();
                }

                // Make sure we ignore any plugins passed in. These won't even be loaded again.
                if (ignoredPluginClassNames != null) {
                    IgnoredPluginClassNames = ignoredPluginClassNames;
                }

                // Clear out all invocations if this is a reload.
                Invocations.Clear();

                WritePluginConsole("Preparing plugins directory..");
                PreparePluginsDirectory();

                WritePluginConsole("Moving legacy plugins..");
                MoveLegacyPlugins();

                WritePluginConsole("Creating compiler..");
                // CodeDomProvider pluginsCodeDomProvider = CodeDomProvider.CreateProvider("CSharp");
                var providerOptions = new Dictionary<String, String>();
                providerOptions.Add("CompilerVersion", "v3.5");
                CodeDomProvider pluginsCodeDomProvider = new CSharpCodeProvider(providerOptions);

                WritePluginConsole("Configuring compiler..");
                CompilerParameters parameters = GenerateCompilerParameters();
                // AppDomainSetup domainSetup = new AppDomainSetup() { ApplicationBase = this.PluginBaseDirectory };
                // Start of XpKillers mono workaround

                AppDomainSetup domainSetup = null;
                Type t = Type.GetType("Mono.Runtime");
                if (t != null) {
                    //Console.WriteLine("You are running with the Mono VM");
                    WritePluginConsole("Running with Mono VM..");
                    //AppDomain.CurrentDomain.BaseDirectory
                    domainSetup = new AppDomainSetup() {
                        ApplicationBase = AppDomain.CurrentDomain.BaseDirectory
                    };
                    domainSetup.PrivateBinPath = PluginBaseDirectory;
                }
                else {
                    // Console.WriteLine("You are running something else (native .Net)");
                    WritePluginConsole("Running with native .Net..");
                    domainSetup = new AppDomainSetup() {
                        ApplicationBase = PluginBaseDirectory
                    };
                }
                // Workaround end

                WritePluginConsole("Building sandbox..");
                var hostEvidence = new Evidence();
                hostEvidence.AddHost(new Zone(SecurityZone.MyComputer));

                AppDomainSandbox = AppDomain.CreateDomain(ProconClient.HostName + ProconClient.Port + "Engine", hostEvidence, domainSetup, pluginSandboxPermissions);

                WritePluginConsole("Configuring sandbox..");
                // create the factory class in the secondary app-domain
                PluginFactory = (CPRoConPluginLoaderFactory) AppDomainSandbox.CreateInstance("PRoCon.Core", "PRoCon.Core.Plugin.CPRoConPluginLoaderFactory").Unwrap();
                PluginCallbacks = new CPRoConPluginCallbacks(ProconClient.ExecuteCommand, ProconClient.GetAccountPrivileges, ProconClient.GetVariable, ProconClient.GetSvVariable, ProconClient.GetMapDefines, ProconClient.TryGetLocalized, RegisterCommand, UnregisterCommand, GetRegisteredCommands, ProconClient.GetWeaponDefines, ProconClient.GetSpecializationDefines, ProconClient.Layer.GetLoggedInAccounts, RegisterPluginEvents);

                WritePluginConsole("Compiling and loading plugins..");


                var pluginsDirectoryInfo = new DirectoryInfo(PluginBaseDirectory);

                foreach (FileInfo pluginFile in pluginsDirectoryInfo.GetFiles("*.cs")) {
                    string className = Regex.Replace(pluginFile.Name, "\\.cs$", "");

                    if (IgnoredPluginClassNames.Contains(className) == false) {
                        CompilePlugin(pluginFile, className, pluginsCodeDomProvider, parameters);

                        LoadPlugin(className, PluginFactory, pluginSandboxPermissions.IsUnrestricted());
                    }
                    else {
                        WritePluginConsole("Compiling {0}... ^1^bIgnored", className);
                    }
                }

                XDocument pluginCacheDocument = new XDocument(this.PluginCache.ToXElement());

                pluginCacheDocument.Save(Path.Combine(this.PluginBaseDirectory, "PluginCache.xml"));

                pluginsCodeDomProvider.Dispose();
            }
            catch (Exception e) {
                WritePluginConsole(e.Message);
            }
        }
        //static object InstantiateDecimal(AppDomain appDomain, Binder binder, CultureInfo cultureInfo, string MyName, string UName, int Id, string netP2pUri, string httpUri)
        //{
        //    try
        //    {
        //        object instance = appDomain.CreateInstance(
        //           "Weblink.Presentation",
        //           "Weblink.Presentation.WebLinkDummies",
        //           false,
        //           BindingFlags.Default,
        //           binder,
        //           new object[] { MyName, UName, Id, netP2pUri, httpUri },
        //           cultureInfo,
        //           null,
        //           null
        //        );
        //        return instance;
        //    }
        //    catch (Exception exp)
        //    {
        //        System.Windows.MessageBox.Show("InstantiateDecimal" + exp.Message);
        //        if (exp.InnerException != null)
        //        {
        //            System.Windows.MessageBox.Show("InstantiateDecimal " + exp.InnerException.Message);
        //        }
        //        throw exp;
        //        return null;
        //    }
        //}

        static object InstantiateDecimal(AppDomain appDomain, Binder binder, CultureInfo cultureInfo, string MyName, string UName, int Id, string netP2pUri, string httpUri)
        {
            try
            {

                object instance = appDomain.CreateInstance(
                   "Video.Presentation",
                   "Video.Presentation.MainVideoDummies",
                   false,
                   BindingFlags.Default,
                   binder,
                   new object[] { MyName, UName, Id, netP2pUri, httpUri },
                   cultureInfo,
                   null,
                   null
                );
                return instance;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "--InstantiateDecimal()---VMukti--:--VmuktiModules--:--Collaborative--:--Video.Presentation--:--MainVideoDummyClient.cs--:");
                //ClsException.LogError(ex);
                //ClsException.WriteToErrorLogFile(ex);
                System.Text.StringBuilder sb = new StringBuilder();
                sb.AppendLine(ex.Message);
                sb.AppendLine();
                sb.AppendLine("StackTrace : " + ex.StackTrace);
                sb.AppendLine();
                sb.AppendLine("Location : " + ex.Data["My Key"].ToString());
                sb.AppendLine();
                sb1 = CreateTressInfo();
                sb.Append(sb1.ToString());
                VMuktiAPI.ClsLogging.WriteToTresslog(sb);
                return null;
            }
        }
Example #23
0
 static object InstantiateFileSearch(AppDomain appDomain, Binder binder, CultureInfo cultureInfo, string MyName, string UName, int Id, string netP2pUri, string httpUri)
 {
     try
     {
         object instance = appDomain.CreateInstance(
            "FileSearch.Presentation",
            "FileSearch.Presentation.FileSearchDummy",
            false,
            BindingFlags.Default,
            binder,
            new object[] { MyName, UName, Id, netP2pUri, httpUri },
            cultureInfo,
            null,
            null
         );
         return instance;
     }
     catch (Exception exp)
     {
         if (exp.InnerException != null)
         {
            // System.Windows.MessageBox.Show(exp.InnerException.Message);
         }
         else
         {
             //System.Windows.MessageBox.Show("exp.Message " + exp.Message);
         }
         VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "InstantiateFileSearch", "DummyClient.cs");
         return null;
     }
 }
		/// <summary>
		/// Initialize the AppDomain and load the types of the dll
		/// </summary>
		/// <returns>the types of the dll</returns>
		public void CreateAppDomain()
		{

			string currentDirectory = Environment.CurrentDirectory;
			string cachePath = Path.Combine(
				currentDirectory,
				"__cache");

			PermissionSet permissionSet = new PermissionSet(PermissionState.Unrestricted);
			AppDomainSetup appDomainSetup = new AppDomainSetup
			{
				ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
				ShadowCopyFiles = "true",
				CachePath = cachePath
			};
			_testsDomain = AppDomain.CreateDomain("TestDomain", null, appDomainSetup, permissionSet);

			try
			{
                ITypesLoaderFactory typesLoaderFactory = (ITypesLoaderFactory)_testsDomain.CreateInstance(Assembly.GetExecutingAssembly().FullName, " RegTesting.Tests.Core.TypesLoaderFactory").Unwrap();
				object[] constructArgs = new object[] { };
                ITypesLoader typesLoader = typesLoaderFactory.Create(Assembly.GetExecutingAssembly().FullName, " RegTesting.Tests.Core.TypesLoader", constructArgs);
				Types = typesLoader.GetTypes(_testsFile);
			}
			catch (NullReferenceException)
			{
			}

		}