从Visual Studio 2017运行ASP.NET核心项目

时间:2017-03-30 05:22:47

标签: asp.net .net asp.net-core

我从命令行创建了ASP.NET Core项目:

./

一切正常。

现在我已经在Visual Studio 2017中打开了这个项目。

  • 调试 - 无需调试即可启动:
  

未处理的异常:System.IO.FileNotFoundException:无法加载   文件或程序集'System.Runtime,Version = 4.1.0.0,Culture = neutral,   PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。该   系统找不到指定的文件。在   System.ModuleHandle.ResolveType(RuntimeModule模块,Int32 typeToken,   IntPtr * typeInstArgs,Int32 typeInstCount,IntPtr * methodInstArgs,   Int32 methodInstCount,ObjectHandleOnStack type)at   System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule模块,   Int32 typeToken,RuntimeTypeHandle [] typeInstantiationContext,   RuntimeTypeHandle [] methodInstantiationContext)at   System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,   键入[] genericTypeArguments,键入[] genericMethodArguments)   System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord   caRecord,MetadataImport范围,汇编& lastAptcaOkAssembly,   RuntimeModule decoratedModule,MetadataToken decoratedToken,   RuntimeType attributeFilterType,Boolean mustBeInheritable,Object []   属性,IList derivedAttributes,RuntimeType&属性类型,   IRuntimeMethodInfo&安培; ctor,布尔& ctorHasParameters,Boolean&   isVarArg)at   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule   decoratedModule,Int32 decoratedMetadataToken,Int32 pcaCount,   RuntimeType attributeFilterType,Boolean mustBeInheritable,IList   derivedAttributes,Boolean isDecoratedTargetSecurityTransparent)at   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly   assembly,RuntimeType caType)at   System.Attribute.GetCustomAttributes(Assembly元素,Type   attributeType,Boolean inherit)at   System.AppDomain.GetTargetFrameworkName()

如何在VS中启动,调试和开发我的项目?

P.S。我知道我可以在VS中创建新项目并且工作正常,但我需要使用从命令行创建的项目。

更新

> dotnet new web
> dotnet restore
> dotnet build
> dotnet run

1 个答案:

答案 0 :(得分:2)

在VS2017中打开并运行dotnet new项目应该有效。

但有时VS会因为奇怪而且莫名其妙而疯狂#34;未找到"依赖和"未编译"新文件 - 然后关闭VS(或卸载项目),手动删除binobj文件夹并重新打开项目。