Razor View参考错误:FileNotFoundException

时间:2015-04-01 07:21:43

标签: asp.net-mvc visual-studio webmatrix-2

我只是修复了使用visual studio 2012的其他人的旧项目。我认为它是基于MVC4构建的,因为它仍然使用WebMatrix.DataWebMatrix.WebData。因为我没有那个vs版本所以我使用visual studio 2013社区版并运行install-package更新。经过几次修复,我试图运行它时遇到了这个问题。以下是错误消息:

    Server Error in '/' Application.
    Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, 
    Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its 
    dependencies. The system cannot find the file specified.
    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 load file or 
    assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system 
    cannot find the file specified.


    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.

    Assembly Load Trace: The following information can be helpful to determine 
    why the assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral,     
    PublicKeyToken=31bf3856ad364e35' could not be loaded.

    === Pre-bind state information ===
    LOG: DisplayName = System.Web.Razor, Version=3.0.0.0, Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35
    (Fully-specified)

    LOG: Appbase = file:///D:/BitBucketGit/DirtOilGas.Website/
    LOG: Initial PrivatePath = D:\BitBucketGit\DirtOilGas.Website\bin

    Calling assembly : System.Web.WebPages.Razor, Version=3.0.0.0, 
    Culture=neutral, PublicKeyToken=31bf3856ad364e35.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: D:\BitBucketGit
    \DirtOilGas.Website\web.config
    LOG: Using host configuration file: C:\Users\amie\Documents\IISExpress
    \config\aspnet.config

    LOG: Using machine configuration file from C:\Windows\Microsoft.NET
    \Framework\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: System.Web.Razor, Version=3.0.0.0, 
    Culture=neutral, PublicKeyToken=31bf3856ad364e35
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET
    /Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a
    /System.Web.Razor.DLL.

    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET
    /Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a
    /System.Web.Razor/System.Web.Razor.DLL.

    LOG: Attempting download of new URL file:///D:/BitBucketGit
    /DirtOilGas.Website/bin/System.Web.Razor.DLL.

    LOG: Attempting download of new URL file:///D:/BitBucketGit
    /DirtOilGas.Website/bin/System.Web.Razor/System.Web.Razor.DLL.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET  
    /Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a    

    /System.Web.Razor.EXE.

    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET  
    /Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a   
    /System.Web.Razor/System.Web.Razor.EXE.

    LOG: Attempting download of new URL file:///D:/BitBucketGit   
    /DirtOilGas.Website/bin/System.Web.Razor.EXE.

     LOG: Attempting download of new URL file:///D:/BitBucketGit
     /DirtOilGas.Website/bin/System.Web.Razor/System.Web.Razor.EXE.


Stack Trace:


    [FileNotFoundException: Could not load file or assembly 'System.Web.Razor, 
    Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one 
    of its dependencies. The system cannot find the file specified.]
    WebMatrix.WebData.PreApplicationStartCode.Start() +0


    [InvalidOperationException: The pre-application start initialization method 
    Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception 
    with the following error message: Could not load file or assembly 
    'System.Web.Razor, Version=3.0.0.0, Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system     
    cannot find the file specified..]  

 System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 
   methods, Func`1 setHostingEnvironmentCultures) +547
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 
   methods) +132

   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String 
   preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager 
   appManager, IApplicationHost appHost, IConfigMapPathFactory 
   configMapPathFactory, HostingEnvironmentParameters hostingParameters, 
   PolicyLevel policyLevel, Exception appDomainCreationException) +521


   [HttpException (0x80004005): The pre-application start initialization method 
   Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception  
   with the following error message: Could not load file or assembly 
   'System.Web.Razor, Version=3.0.0.0, Culture=neutral, 
   PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system 
   cannot find the file specified..]

   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930508
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest 
   wr, HttpContext context) +254

    Server Error in '/' Application.
Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
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 load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

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.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.


=== Pre-bind state information ===
LOG: DisplayName = System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///D:/BitBucketGit/DirtOilGas.Website/
LOG: Initial PrivatePath = D:\BitBucketGit\DirtOilGas.Website\bin
Calling assembly : System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\BitBucketGit\DirtOilGas.Website\web.config
LOG: Using host configuration file: C:\Users\amie\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///D:/BitBucketGit/DirtOilGas.Website/bin/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///D:/BitBucketGit/DirtOilGas.Website/bin/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a/System.Web.Razor/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///D:/BitBucketGit/DirtOilGas.Website/bin/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///D:/BitBucketGit/DirtOilGas.Website/bin/System.Web.Razor/System.Web.Razor.EXE.


Stack Trace:


[FileNotFoundException: Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   WebMatrix.WebData.PreApplicationStartCode.Start() +0

[InvalidOperationException: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +547
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930508
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

1 个答案:

答案 0 :(得分:0)

手动解决方案的发现可能需要一些时间只需右键单击项目,然后单击“管理Nuget包”。 ,搜索' Microsoft ASP.NET Razor'并安装版本3.2.3。它将更新所需的程序集和引用。 希望它会对你有所帮助。