启动ASP.NET Core应用程序时找不到System.Runtime

时间:2017-04-08 12:17:23

标签: c# asp.net

我发布了一个Web应用程序(使用VS 2015)。 当我运行.dll时,我收到一条错误消息:

  

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

(这很奇怪,因为它说即使在简单的空白应用程序......)

这是project.json文件:

{
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.1.1",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.1",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Modules": "1.0.0-*"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config",
      "config.json",
      "Views"
    ]
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "scripts": {
    "prepublish": [ "bower install" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-preview2-final" },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  }
}

Modules project.json:

{
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.1.1",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.1",
    "Microsoft.Extensions.Configuration.Abstractions": "1.0.0",
    "NETStandard.Library": "1.6.1",
    "Microsoft.EntityFrameworkCore.Tools": {
      "type": "build",
      "version": "1.0.0-preview2-final"
    },
    "Microsoft.AspNetCore.Mvc.WebApiCompatShim": "1.0.0",
    "Microsoft.AspNetCore.Routing": "1.0.0",
    "MailKit": "1.10.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  }
}

任何人都知道会出现什么问题?

1 个答案:

答案 0 :(得分:0)

这是因为您必须使用 dotnet run .dll 而不是 ./.dll 运行 dll。 dotnet 框架将为您完成剩下的工作。