我尝试在ASP.Net 5 Beta 3中使用Aftership SDK,但即使我已将其添加为依赖项,我仍然会收到以下错误:
Microsoft.Framework.Runtime.Roslyn.RoslynCompilationException:
~/myproject/Controllers/PackagesController.cs(5,7):
error CS0246: The type or namespace name 'Aftership' could not be
found (are you missing a using directive or an assembly reference?)
所有相关的SO问题都说要从packages.json
文件中删除CoreCLR框架参考,但我已经这样做了:
{
"webroot": "wwwroot",
"exclude": "wwwroot/**/*.*",
"dependencies": {
"Microsoft.AspNet.Server.IIS":"1.0.0-beta3",
"Microsoft.AspNet.Mvc": "6.0.0-beta3",
"Microsoft.AspNet.Hosting": "1.0.0-beta3",
"Microsoft.AspNet.Security.Cookies": "1.0.0-beta3",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta3",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
"Kestrel": "1.0.0-beta3",
"Aftership": "4.0.8"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001",
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004"
},
"frameworks": {
"aspnet50": { }
}
}
我的控制器代码是标准的:
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Mvc;
using Mirror.Models;
using Aftership;
using System.Linq;
namespace Mirror.Controllers
{
public class PackagesController : Controller
{
public IActionResult Index()
{
return View(GetPackages());
}
private List<Package> GetPackages()
{
var packages = new List<Package>();
var conn = new ConnectionAPI("...");
...
}
}
}
运行kpm restore
后,我可以找到位于我的包目录下的库:~/.k/packages/Aftership/4.0.8/lib/net40/Aftership-API.exe
问题可能是由于Aftership库提供的是exe而不是恰当的名称Aftership.dll
吗?我试图重命名该文件,但没有成功......
答案 0 :(得分:1)
我最终只是自己编译成一个DLL(这意味着我也可以将.Net 4.5作为目标),并为它构建一个私有的NuGet包。感谢开源软件!
感谢@Elion确认DLL是唯一受支持的引用。