2015-04-01 111 views
0

我剛剛修復了其他人使用visual studio 2012的舊項目。我認爲它是建立在MVC4上,因爲它仍然使用WebMatrix.DataWebMatrix.WebData。因爲我沒有vs版本,所以我使用的是Visual Studio 2013社區版,並運行安裝包更新。修好之後,我試着運行它時遇到了這個問題。以下是錯誤消息:剃刀Vew參考錯誤

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 
+0

也有類似的問題關於SO,http://stackoverflow.com/questions/19959406/runtime-error-could-not-load-file-or-assembly-system-web-webpages-razor-versi – SBirthare 2015-04-01 07:28:25

回答

0

手動解決方案結果可能需要時間。只需右鍵單擊項目,然後單擊「管理Nuget包」,搜索「Microsoft ASP.NET Razor」並安裝版本3.2.3。它會更新所需的組件和參考。 希望它能幫助你。