编程语言
首页 > 编程语言> > c#-类型’IEnumerable <>'是在未引用的程序集中定义的.系统运行时

c#-类型’IEnumerable <>'是在未引用的程序集中定义的.系统运行时

作者:互联网

我有一个引用类库的asp.net 5 Web应用程序.

该类库使用Entity Framework 7执行查询.

public IEnumerable<Member> GetMemberyByFirstName(string firstName)
{
    var members = _context.Members.Where(m => m.FirstName.Contains(firstName));
    return memebers;
}

但是我得到这个编译错误

The type ‘IEnumerable<>’ is defined in an assembly that is not
referenced. You must add a reference to assembly ‘System.Runtime,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.
*

解决方法:

我已经想出了如何做到这一点,但只想提供这些信息.

这非常复杂,围绕project.json展开.

简短的答案是我将类库中的project.json更改为

{
    "version": "1.0.0-*",
    "description": "Member.Business Class Library",
    "authors": [ "bryan" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",
    "frameworks": {
        "dnx451": { },
        "dnxcore50": {  
            "dependencies": {
               "Microsoft.CSharp": "4.0.1-beta-23516"
            }
        }
    },
    "dependencies": {
        "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
        "Member.DataLayer": "1.0.0-*",
        "Member.Domain": "1.0.0-*",
        "System.Collections": "4.0.11-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Runtime": "4.0.21-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
    }
}

可以在这里找到更多详细信息-http://nodogmablog.bryanhogan.net/2016/01/the-type-is-defined-in-an-assembly-that-is-not-referenced-system-runtime/

标签:asp-net-core,entity-framework-core,project-json,c
来源: https://codeday.me/bug/20191119/2034047.html