2016-07-24 9 views
2

Ich versuche, aus MVC6 beta (6.0.0-rc1-final) auf dem neuesten ASP.NET-Core 1.0.0Identität existiert nicht im Namensraum 'Microsoft.AspNetCore'

ich ein Upgrade geschaffen zu aktualisieren meine Anwendung mit asp.net-Dokumentationshilfe.

Aber jetzt, wenn ich meine Anwendung mit STRG + F5 ausführen, es gibt mir Fehler für /Views/_ViewImports.cshtml File-

„Der Typ oder Namespace-Name‚Identität‘existiert nicht in der Namespace 'Microsoft.AspNetCore'“

Complete error snap here

Unten ist mein 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 

Wenn Sie meine _ViewImports.cshtml Datei oben sehen, hat sie Identity-Namespace.

Bitte führen Sie mich an, wie Sie diesen Laufzeitfehler beheben können.

Meine Umgebung is- VS2015 Community Edition und ASP.NET core1.0 und .NET Framework 4.6.1

Vielen Dank im Voraus.

+0

Haben Sie 'dotnet restore' ausgeführt? – poke

+0

ja ... aber kein Glück! Ich kann Microsoft.AspNetCore.Identity in meiner Referenz sehen und mein Projekt baut erfolgreich auf. – Sachin411

Antwort

5

Try "preserveCompilationContext": true in Ihrem project.json

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

Zugabe Sehen Sie, ob das hilft.


EDIT:

preserveCompilationContext erforderlich, wenn Sie Razor oder jede andere Art von Laufzeit Compilieren verwenden. Ohne sie schlägt die Laufzeitkompilierung von Razor-Ansichten fehl.

Weitere Informationen finden Sie unter this link.

+0

Ich werde es versuchen. aber was bedeutet das? – Sachin411

+0

siehe aktualisierte Antwort oben. – Sanket

+0

Danke :) das hat funktioniert/Ihre Antwort markiert – Sachin411

Verwandte Themen