2016-07-24 29 views
2

我試圖從MVC6β(6.0.0-RC1決賽)升級到最新的ASP.NET核心1.0.0身份沒有命名空間中存在「Microsoft.AspNetCore」

我設法升級我應用程序使用asp.net文檔幫助。

但是現在,當我運行使用CTRL + F5我的應用程序,它給了我錯誤/Views/_ViewImports.cshtml文件 -

「的類型或命名空間名稱‘身份’不存在的命名空間 'Microsoft.AspNetCore'」

Complete error snap here

下面是我global.json-

{ 
    "projects": [ "src", "test" ], 
    "sdk": { 
    "version": "1.0.0-preview2-003121" 
    } 
} 

的package.json

{ 
    "name": "Apex", 
    "version": "2.4.0", 
    "devDependencies": { 
    "gulp": "3.8.11", 
    "gulp-concat": "2.5.2", 
    "gulp-cssmin": "0.1.7", 
    "gulp-uglify": "1.2.0", 
    "rimraf": "2.2.8", 
    "gulp-sass": "2.1.1", 
    "node-sass": "3.4.2" 
    } 
} 

appsettings.json

{ 
    "ApplicationInsights": { 
    "InstrumentationKey": "" 
    }, 
    "Data": { 
    "DefaultConnection": { 
     "ConnectionString": "" 
    } 
    }, 
    "Logging": { 
    "IncludeScopes": false, 
    "LogLevel": { 
     "Default": "Verbose", 
     "System": "Information", 
     "Microsoft": "Information" 
    } 
    } 
} 

project.json

{ 
    "userSecretsId": "", 

    "buildOptions": { 
    "emitEntryPoint": true 
    }, 

    "dependencies": { 
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0", 
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0", 
    "Microsoft.AspNetCore.Diagnostics": "1.0.0", 
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0", 
    "Microsoft.AspNetCore.Identity": "1.0.0", 
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0", 
    "Microsoft.AspNetCore.Mvc": "1.0.0", 
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0", 

    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", 
    "Microsoft.AspNetCore.StaticFiles": "1.0.0", 
    "Microsoft.EntityFrameworkCore": "1.0.0", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", 
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0", 
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0", 
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", 
    "Microsoft.Extensions.Logging": "1.0.0", 
    "Microsoft.Extensions.Logging.Console": "1.0.0", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0", 
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", 
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.0.0-preview2-final" 
    }, 

    "tools": { 
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", 
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final" 
    }, 

    "commands": { 
    "ef": "EntityFramework.Commands", 
    "web": "Microsoft.AspNetCore.Server.Kestrel" 
    }, 

    "frameworks": { 
    "net461": {} 
    }, 

    "publishOptions": { 
    "exclude": [ 
     "**.user", 
     "**.vspscc", 
     "wwwroot", 
     "node_modules" 
    ] 
    }, 

    "scripts": { 
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ] 
    } 
} 

_ViewImports.cshtml

@using MVC6_Full_Version 
@using MVC6_Full_Version.Models 
@using MVC6_Full_Version.ViewModels.Account 
@using MVC6_Full_Version.ViewModels.Manage 
@using Microsoft.AspNetCore.Identity 

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 
@inject Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration TelemetryConfiguration 

如果您在上面看到我的_ViewImports.cshtml文件,它具有Identity名稱空間。

請指導我如何解決此運行時錯誤。

我的環境是 - VS2015社區版和ASP.NET core1.0和.NET Framework 4.6.1

在此先感謝。

+0

你運行過'dotnet restore'嗎? – poke

+0

是的......但沒有運氣!我可以在我的參考中看到Microsoft.AspNetCore.Identity,並且我的項目正在成功建立。 – Sachin411

回答

5

嘗試在project.json

"buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true 
    }, 

加入"preserveCompilationContext": true看看這會有所幫助。


編輯:

preserveCompilationContext是當您使用剃刀或任何其他類型的運行時編譯的需要。沒有它,Razor視圖的運行時編譯將失敗。請參閱this link

+0

我會盡力的。但這是什麼意思? – Sachin411

+0

查看上面更新的答案。 – Sanket

+0

謝謝:)工作/標記你的答案 – Sachin411

相關問題