Example #1
0
        protected DomainExtractorPair GetExtractorInTempAppDomain(string assemblyPath)
        {
            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase = Path.GetDirectoryName(assemblyPath);
            setup.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);

            Interlocked.Increment(ref _domainID);

            string appDomainName = Constants.ExtractionDomainPrefix + " " + _domainID.ToString();
            string typeName = new AssemblyExtractor().GetType().FullName; // Do it this way to work with obfuscator
            string extractorPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BitDiffer.Extractor.dll");

            Log.Verbose("Creating {0}", appDomainName);
            AppDomain domain = AppDomain.CreateDomain(appDomainName, evidence, setup);
            AssemblyExtractor extractor = (AssemblyExtractor)domain.CreateInstanceFromAndUnwrap(extractorPath, _extractorTypeName);

            // When running in another app domain - need to copy the Visual Studio trace listeners over.
            // This allows unit tests running in the other AppDomain to have their trace output displayed in the Visual Studio trace output.
            // TraceListener is MarshalByRef so this is safe.
            foreach (TraceListener listener in Trace.Listeners)
            {
                if (listener.Name == "")
                {
                    extractor.AddTraceListener(listener);
                }
            }

            return new DomainExtractorPair(domain, extractor);
        }
Example #2
0
		public DomainExtractorPair(AppDomain domain, AssemblyExtractor extractor)
		{
			_domain = domain;
			_extractor = extractor;
		}
Example #3
0
 static AssemblyManager()
 {
     _extractorTypeName = new AssemblyExtractor().GetType().FullName; // Do it this way to work with obfuscator
 }