Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 289 Vote(s) - 3.69 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Could not find file PrecompiledApp.config when working with precompiled Razor views and VirtualPathProviders

#1
We have an application using WebForms .aspx files for just about everything. Latley we have been using precompiled RazorViews as a way of getting nicley packeted functionality by simply dropping a new dll in our project. But now we have discoverd that our precompiled views seems to conflict with our VirtualPathProviders.

When loading VirtualPathProviders from external dlls the application tries to load PrecompiledApp.config for all requests (and we don't got it). The providers are loaded with reflection. We have some VirtualPathProviders in the same project as the registration and they work fine but when we register providers from external dlls with `HostingEnvironment.RegisterVirtualPathProvider` we get this problem.

If we add the file PrecompiledApp.config it tries to get _appstart.cshtml and so on. We have to have all theese files below before getting past the exeption:

- PrecompiledApp.config
- _appstart.cshtml
- _PageStart.cshtml
- _ViewStart.cshtml
- Views/_ViewStart.cshtml
- Views/Shared/_ViewStart.cshtml
- default.cshtml

We end up in default.cshtml and the rest of the application works. Since we want to use apsx-files as the default this is not an acceptable solution. We are also worried that more problems will appear from this since we have no idea of why this is happening.

We have tried this way of loading our providers but we still get the same error:
[

[To see links please register here]

][1]



**The Exception:**

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


[1]:

[To see links please register here]

Reply

#2
Are you sure that the FileExists of your VirtualPathProvider returns false for PrecompiledApp.config?

The IsNonUpdatablePrecompiledApp flag invokes the FileExists on the vpp before it actually call Open, to prevent your exception from happening.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through