1

Closed

dynamic compilation attempts to compile dlls causing exceptions

description

while investigating DefaultBuildManager inside
  public Assembly GetCompiledAssembly(string virtualPath) {
            try {
                     return BuildManager.GetCompiledAssembly(virtualPath);     
                }
            }
            catch ( ) {
                
                return null;
            }

            
        }
i noticed hundreds of exceptions raised with message
System.Web.HttpException (0x80004005): There is no build provider registered for the extension '.dll'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
   at System.Web.Compilation.CompilationUtil.GetBuildProviderTypeFromExtension(CompilationSection config, String extension, BuildProviderAppliesTo neededFor, Boolean failIfUnknown)
   at System.Web.Compilation.BuildManager.CreateBuildProvider(VirtualPath virtualPath, BuildProviderAppliesTo neededFor, CompilationSection compConfig, ICollection referencedAssemblies, Boolean failIfUnknown)
   at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetCompiledAssembly(String virtualPath)
   at Orchard.Environment.DefaultBuildManager.GetCompiledAssembly(String virtualPath) in D:\GiannisDocuments\orchard16\src\Orchard\Environment\IBuildManager.cs:line 55
   
It seems its trying to pass in dll files to compile causing these exceptions.
I dont know why it would try this as only csproj need compilation. i guess.

I went and added this code in core to ignore dll files from compiling
  public Assembly GetCompiledAssembly(string virtualPath) {
            try {
                //ignore files with .dll extension from dynamic compilation 
                var extension = System.IO.Path.GetExtension(virtualPath);
                if (extension != null && !extension.Equals(".dll"))
                {
                     return BuildManager.GetCompiledAssembly(virtualPath);     

                }
            }
            catch (Exception ex) {
                //log compilation error
                Logger.Log(LogLevel.Error, ex,  "Error during dynamic compilation. Error Message: {0} ", ex.ToString());
               
                return null;
            }

            return null;
        }
The exceptions where gone and dynamic compilation seems to work correctly.

Unless I am missing something here, I would suggest to not include dlls for compilation , maybe we will gain some performance benefit too.

Yiannis.
Closed May 28, 2013 at 9:08 PM by sebastienros

comments

sebastienros wrote May 22, 2013 at 10:52 PM

Which version of Orchard ?

sebastienros wrote May 22, 2013 at 10:56 PM

And when you hit the exception, what is the stacktrace ? I am looking at the code in 1.x and can't find how it could pass a dll to it.

giannik wrote May 23, 2013 at 7:18 AM

Version 6.
I originally saw this by catching the exceptions by placing a breakpoint inside the GetCompiledAssembly method (break inside the catch block). You can can see there the stack trace and everything.
Yiannis.

giannik wrote May 23, 2013 at 7:18 AM

i mean version 1.6.
sorry.

sebastienros wrote May 23, 2013 at 4:19 PM

It's not happening for me on 1.x, so I will close the issue unless you can repro it on 1.x too.

manudea wrote Feb 26 at 9:11 PM

It just happened on server 2012... latest 1.x code... here it is the stack trace:

2014-02-26 21:08:37,408 [3] Orchard.Environment.DefaultBuildManager - Default - Error when compiling assembly under ~/Modules/NGM.OpenAuthentication/packages/DotNetOpenAuth.AspNet.4.3.1.13153/lib/net40-full/DotNetOpenAuth.AspNet.dll.
System.Web.HttpException (0x80004005): There is no build provider registered for the extension '.dll'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
at System.Web.Compilation.CompilationUtil.GetBuildProviderTypeFromExtension(CompilationSection config, String extension, BuildProviderAppliesTo neededFor, Boolean failIfUnknown)
at System.Web.Compilation.BuildManager.CreateBuildProvider(VirtualPath virtualPath, BuildProviderAppliesTo neededFor, CompilationSection compConfig, ICollection referencedAssemblies, Boolean failIfUnknown)
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetCompiledAssembly(String virtualPath)
at Orchard.Environment.DefaultBuildManager.GetCompiledAssembly(String virtualPath) in c:\dev\Progetti\Marketing Manager\Ecommerce\Orchard\src\Orchard\Environment\IBuildManager.cs:line 53

manudea wrote Feb 26 at 9:25 PM

one more issue. It seem that picks all *.dll outside bin...

2014-02-26 21:23:10,431 [14] Orchard.Environment.DefaultBuildManager - Default - Error when compiling assembly under ~/Modules/FacebookSDK/Libs/Facebook.dll.
System.Web.HttpException (0x80004005): There is no build provider registered for the extension '.dll'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
at System.Web.Compilation.CompilationUtil.GetBuildProviderTypeFromExtension(CompilationSection config, String extension, BuildProviderAppliesTo neededFor, Boolean failIfUnknown)
at System.Web.Compilation.BuildManager.CreateBuildProvider(VirtualPath virtualPath, BuildProviderAppliesTo neededFor, CompilationSection compConfig, ICollection referencedAssemblies, Boolean failIfUnknown)
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetCompiledAssembly(String virtualPath)
at Orchard.Environment.DefaultBuildManager.GetCompiledAssembly(String virtualPath) in c:\dev\Progetti\Marketing Manager\Ecommerce\Orchard\src\Orchard\Environment\IBuildManager.cs:line 53