From 31c50ab7aa778171d7e4dba0c846cb18ed09e14f Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Mon, 27 Nov 2006 19:24:29 +0000 Subject: [PATCH] App_Code assemblies fix svn path=/trunk/mcs/; revision=68528 --- .../System.Web.Compilation/CachingCompiler.cs | 26 ++++++++++++++++++- .../System.Web.Compilation/ChangeLog | 3 +++ mcs/class/System.Web/System.Web.UI/ChangeLog | 5 ++++ .../System.Web.UI/SimpleWebHandlerParser.cs | 22 +++++++++++++--- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs b/mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs index 72b14133437..40f1b28dc22 100644 --- a/mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs +++ b/mcs/class/System.Web/System.Web.Compilation/CachingCompiler.cs @@ -123,6 +123,9 @@ namespace System.Web.Compilation SimpleWebHandlerParser parser = compiler.Parser; CompilerParameters options = compiler.CompilerOptions; options.IncludeDebugInformation = parser.Debug; +#if NET_2_0 + GetExtraAssemblies (options); +#endif results = compiler.Compiler.CompileAssemblyFromFile (options, compiler.InputFile); string [] deps = (string []) parser.Dependencies.ToArray (typeof (string)); cache.InsertPrivate (key, results, new CacheDependency (deps)); @@ -143,7 +146,9 @@ namespace System.Web.Compilation foreach (string str in assemblies) coll.Add (str); } - +#if NET_2_0 + GetExtraAssemblies (options); +#endif return options; } @@ -225,6 +230,25 @@ namespace System.Web.Compilation return type; } +#if NET_2_0 + static void GetExtraAssemblies (CompilerParameters options) + { + ArrayList al = WebConfigurationManager.ExtraAssemblies; + if (al != null && al.Count > 0) { + foreach (object o in al) + if (o is string) + options.ReferencedAssemblies.Add ((string) o); + } + + IList list = BuildManager.CodeAssemblies; + if (list != null && list.Count > 0) { + foreach (object o in list) + if (o is string) + options.ReferencedAssemblies.Add ((string) o); + } + } +#endif + static bool AcquireCompilationTicket (string key, out object ticket) { lock (compilationTickets.SyncRoot) { diff --git a/mcs/class/System.Web/System.Web.Compilation/ChangeLog b/mcs/class/System.Web/System.Web.Compilation/ChangeLog index 4d20ccf5167..4d297bbcedd 100644 --- a/mcs/class/System.Web/System.Web.Compilation/ChangeLog +++ b/mcs/class/System.Web/System.Web.Compilation/ChangeLog @@ -1,5 +1,8 @@ 2006-11-27 Marek Habersack + * CachingCompiler.cs: Automatically reference App_Code + assemblies. + * AppCodeCompiler.cs: Add ~/bin/*.dll to the referenced assemblies when compiling. diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog index 903e7ba07b8..bb8c55b2c91 100644 --- a/mcs/class/System.Web/System.Web.UI/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI/ChangeLog @@ -1,3 +1,8 @@ +2006-11-27 Marek Habersack + + * SimpleWebHandlerParser.cs: Added support for looking up types in + the top-level assemblies (App_Code et al) + 2006-11-27 Igor Zelmanovich * Control.cs: implemented EnsureID method. diff --git a/mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs b/mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs index bbc587116e1..50e9f9e1c2f 100644 --- a/mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs +++ b/mcs/class/System.Web/System.Web.UI/SimpleWebHandlerParser.cs @@ -351,11 +351,27 @@ namespace System.Web.UI internal Type GetTypeFromBin (string typeName) { + Type result = null; +#if NET_2_0 + IList toplevelAssemblies = BuildManager.TopLevelAssemblies; + if (toplevelAssemblies != null && toplevelAssemblies.Count > 0) { + foreach (Assembly asm in toplevelAssemblies) { + Type type = asm.GetType (typeName, false); + if (type != null) { + if (result != null) + throw new HttpException (String.Format ("Type {0} is not unique.", typeName)); + } + result = type; + } + } +#endif if (!Directory.Exists (PrivateBinPath)) - throw new HttpException (String.Format ("Type {0} not found.", typeName)); - + if (result == null) + throw new HttpException (String.Format ("Type {0} not found.", typeName)); + else + return result; + string [] binDlls = Directory.GetFiles (PrivateBinPath, "*.dll"); - Type result = null; foreach (string dll in binDlls) { Assembly assembly = Assembly.LoadFrom (dll); Type type = assembly.GetType (typeName, false); -- 2.25.1