Пример #1
0
        public static void ExtraDisposesIgnored()
        {
            TypeLoader tl = new TypeLoader();

            tl.LoadFromByteArray(TestData.s_SimpleAssemblyImage);
            tl.Dispose();
            tl.Dispose();
            tl.Dispose();
        }
Пример #2
0
        public static void TypeLoaderApisAfterDispose()
        {
            TypeLoader tl = new TypeLoader();

            tl.Dispose();

            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromAssemblyName(new AssemblyName("Foo")));
            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromAssemblyName("Foo"));
            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromAssemblyPath("Foo"));
            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromByteArray(TestData.s_SimpleAssemblyImage));
            Assert.Throws <ObjectDisposedException>(() => tl.LoadFromStream(new MemoryStream(TestData.s_SimpleAssemblyImage)));
        }
Пример #3
0
        //
        // Clean up the cache entry for the given assembly, so that it can be reloaded for the next build cycle.
        // Usually it is called by MarkupCompiler task.
        //
        internal static void ResetCacheForAssembly(string assemblyName)
        {
            string assemblyNameLookup = assemblyName.ToUpper(CultureInfo.InvariantCulture);

#if PBTCOMPILER
            // TODO: PresentationBuildTasks porting : Reset TypeLoader between compile passes.
            // Do not do this here, which will recreate the entire TypeLoader. There doesn't
            // appear to be way to release a specific assembly in TypeLoader.
            //
            // Explicitly dispose and re-create the TypeLoader to release all assemblies.
            // The intermediate assembly created by MarkupCompilePass1 is used as a reference
            // and needs to be writable in compile pass 2.
            _typeLoader.Dispose();
            _cachedTypeLoaderAssemblies.Clear();
            _cachedTypeLoaderReferencePaths.Clear();
            _typeLoader = new TypeLoader();
            _reflectionOnlyLoadedAssembliesHash[assemblyNameLookup] = null;
#else
            _loadedAssembliesHash[assemblyNameLookup] = null;
#endif
        }
Пример #4
0
 /// <summary>
 /// Dispose the instance.
 /// </summary>
 public void Dispose()
 {
     _loader.Dispose();
 }