【发布时间】:2015-12-18 21:34:58
【问题描述】:
我正在我的 Mac 上试用新的 Core CLR 类型 ASP.Net,并且遇到了无穷无尽的问题。
我已经设法通过 dnu 和 dnu restore 引用并安装了 StructureMap,但现在我在 VS Code 中遇到错误,指出:
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. [dnx451]
我已经进行了大量的谷歌搜索,但我只能找到说明我需要添加一个 using for System 的东西,但这并不能解决问题。
Startup.cs:
using System;
using System.Reflection;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Extensions.DependencyInjection;
using StructureMap;
namespace Authorization
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public IServiceProvider ConfigureServices(IServiceCollection services)
{
var container = new Container();
container.Configure(x => {
x.Scan(scanning => {
scanning.Assembly(Assembly.GetExecutingAssembly());
scanning.TheCallingAssembly();
scanning.WithDefaultConventions();
});
});
container.Populate(services);
return container.GetInstance<IServiceCollection>(services);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.UseIISPlatformHandler();
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}
// Entry point for the application.
public static void Main(string[] args) => Microsoft.AspNet.Hosting.WebApplication.Run<Startup>(args);
}
}
project.json:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"tooling": {
"defaultNamespace": "Authorization"
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"StructureMap.Dnx": "0.4.0-alpha4"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {},
"dnxcore50": {}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
感谢您的帮助!
谢谢
【问题讨论】:
-
您是否尝试删除 dnxcore50 并从 dnx451 运行?当它针对两个框架之一时,它可能会失败。
-
同样的事情 - 再次运行 dnu restore,没有变化
-
假设您也尝试了相反的操作?
标签: c# .net asp.net-core dnx coreclr