2012-05-03 28 views
23

Tenemos una aplicación que utiliza archivos .aspx de WebForms para casi todo. Latley hemos estado utilizando RazorViews precompilados como una forma de obtener una funcionalidad empaquetada sin problemas simplemente colocando un nuevo dll en nuestro proyecto. Pero ahora descubrimos que nuestras vistas precompiladas parecen estar en conflicto con nuestros VirtualPathProviders.No se pudo encontrar el archivo PrecompiledApp.config cuando se trabaja con vistas premezcladas Razor y VirtualPathProviders

Al cargar VirtualPathProviders desde dlls externos, la aplicación intenta cargar PrecompiledApp.config para todas las solicitudes (y no lo tenemos). Los proveedores están cargados de reflexión. Tenemos algunos VirtualPathProviders en el mismo proyecto que el registro y funcionan bien, pero cuando registramos proveedores de dlls externos con HostingEnvironment.RegisterVirtualPathProvider obtenemos este problema.

Si agregamos el archivo PrecompiledApp.config, intenta obtener _appstart.cshtml y así sucesivamente. Tenemos que tener todos los archivos theese a continuación antes de conseguir más allá de la excepcion:

  • PreCompiledApp.config
  • _appstart.cshtml
  • _PageStart.cshtml
  • _ViewStart.cshtml
  • Vistas/_ViewStart.cshtml
  • Vistas/Común/_ViewStart.cshtml
  • default.cshtml

Terminamos en default.cshtml y el resto de la aplicación funciona. Como queremos utilizar archivos apsx como predeterminados, esta no es una solución aceptable. También nos preocupa que aparezcan más problemas debido a que no tenemos idea de por qué está sucediendo esto.

Nos han tratado de esta manera de la carga de nuestros proveedores, pero que aún así obtener el mismo error: http://sunali.com/2008/01/09/virtualpathprovider-in-precompiled-web-sites/

La Excepción:

Could not find file 'C:\MyApp\PrecompiledApp.config'. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileNotFoundException: Could not find file 'C:\MyApp\PrecompiledApp.config'. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


[FileNotFoundException: Could not find file 'C:\MyApp\PrecompiledApp.config'.] 
    System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +12899479 
    System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) +2481 
    System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +229 
    System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +102 
    System.Web.Hosting.MapPathBasedVirtualFile.Open() +105 
    System.Web.WebPages.BuildManagerWrapper.IsNonUpdatablePrecompiledApp() +157 
    System.Web.WebPages.BuildManagerWrapper..ctor(VirtualPathProvider vpp, IVirtualPathUtility virtualPathUtility) +48 
    System.Web.WebPages.VirtualPathFactoryManager.<.cctor>b__6() +90 
    System.Lazy`1.CreateValue() +12776623 
    System.Lazy`1.LazyInitValue() +355 
    System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application) +131 
    System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application, Action`1 executeStartPage, EventHandler applicationStart) +98 
    System.Web.WebPages.WebPageHttpModule.InitApplication(HttpApplication application) +75 
    System.Web.WebPages.WebPageHttpModule.Init(HttpApplication application) +268 
    System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +575 
    System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352 
    System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407 
    System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375 

[HttpException (0x80004005): Could not find file 'C:\MyApp\PrecompiledApp.config'.] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700992 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869221 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

Respuesta

3

¿Estas seguro que los FileExists de su VirtualPathProvider devuelve false para PrecompiledApp.config?

El indicador IsNonUpdatablePrecompiledApp invoca FileExists en la vpp antes de que realmente llame a Open, para evitar que suceda una excepción.

Cuestiones relacionadas