Skip to content

Commit

Permalink
Backport of r76378
Browse files Browse the repository at this point in the history
2007-04-27  Marek Habersack  <mhabersack@novell.com>
  
	* AppCodeCompiler.cs: Resolve assembly names from the global web.config to their
	locations before passing them to the compiler provider.

svn path=/branches/mono-1-2-4/mcs/; revision=76475
  • Loading branch information
grendello committed Apr 30, 2007
1 parent 32732d4 commit 0b8b41b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
48 changes: 45 additions & 3 deletions mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs
Expand Up @@ -44,6 +44,48 @@

namespace System.Web.Compilation
{
class AssemblyPathResolver
{
static Dictionary <string, string> assemblyCache;

static AssemblyPathResolver ()
{
assemblyCache = new Dictionary <string, string> ();
}

public static string GetAssemblyPath (string assemblyName)
{
lock (assemblyCache) {
if (assemblyCache.ContainsKey (assemblyName))
return assemblyCache [assemblyName];

Assembly asm = null;
Exception error = null;
if (assemblyName.IndexOf (',') != -1) {
try {
asm = Assembly.Load (assemblyName);
} catch (Exception e) {
error = e;
}
}

if (asm == null) {
try {
asm = Assembly.LoadWithPartialName (assemblyName);
} catch (Exception e) {
error = e;
}
}

if (asm == null)
throw new HttpException (String.Format ("Unable to find assembly {0}", assemblyName), error);

assemblyCache.Add (assemblyName, asm.Location);
return asm.Location;
}
}
}

internal class AppCodeAssembly
{
private List<string> files;
Expand Down Expand Up @@ -190,8 +232,8 @@ public void Build (string[] binAssemblies)
foreach (AssemblyInfo ai in compilationSection.Assemblies)
if (ai.Assembly != "*") {
try {
asmName = new AssemblyName (ai.Assembly);
parameters.ReferencedAssemblies.Add (asmName.Name);
parameters.ReferencedAssemblies.Add (
AssemblyPathResolver.GetAssemblyPath (ai.Assembly));
} catch (Exception ex) {
throw new HttpException (
String.Format ("Could not find assembly {0}.", ai.Assembly),
Expand Down Expand Up @@ -230,7 +272,7 @@ public void Build (string[] binAssemblies)
throw new CompilationException (null, results.Errors, null);
}
}

private string PhysicalToVirtual (string file)
{
return file.Replace (HttpRuntime.AppDomainAppPath, "/").Replace (Path.DirectorySeparatorChar, '/');
Expand Down
4 changes: 3 additions & 1 deletion mcs/class/System.Web/System.Web.Compilation/ChangeLog
Expand Up @@ -2,7 +2,9 @@

* AppCodeCompiler.cs: do not look at the number of errors, check
the compiler return code instead.

Resolve assembly names from the global web.config to their
locations before passing them to the compiler provider.

* AssemblyBuilder.cs: as above

* AppResourcesCompiler.cs: as above
Expand Down

0 comments on commit 0b8b41b

Please sign in to comment.