简体   繁体   English

“IEnumerable <>”类型在未引用的程序集中定义。 System.Runtime

[英]The type 'IEnumerable<>' is defined in an assembly that is not referenced. System.Runtime

I have an asp.net 5 web application that references a class library. 我有一个引用类库的asp.net 5 Web应用程序。

That class library use Entity Framework 7 to perform a query. 该类库使用Entity Framework 7来执行查询。

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

But I get this compile error 但是我得到了这个编译错误

The type 'IEnumerable<>' is defined in an assembly that is not referenced. “IEnumerable <>”类型在未引用的程序集中定义。 You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 您必须添加对程序集'System.Runtime,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的引用。 * *

I already figured out how to do this but just wanted the info to available. 我已经想出如何做到这一点,但只是希望信息可用。

It's quite complicated and revolves around the project.json. 它非常复杂,围绕着project.json。

The very short answer is I changed the project.json in the class library to 很简单的答案是我将类库中的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"
    }
}

Much more detail can be found here - http://nodogmablog.bryanhogan.net/2016/01/the-type-is-defined-in-an-assembly-that-is-not-referenced-system-runtime/ 可以在这里找到更多细节 - http://nodogmablog.bryanhogan.net/2016/01/the-type-is-defined-in-an-assembly-that-is-not-referenced-system-runtime/

try returning like below- 尝试返回如下 -

var members = _context.Members.Where(m => m.FirstName.Contains(firstName)).ToList();

Also, I don't understand function definition- 另外,我不明白功能定义 -

void IEnumerable<Member>

If you want to return IEnumerable<Member> it should only be IEnumerable<Member> and not void IEnumerable<Member> 如果你想返回IEnumerable<Member>它应该只是IEnumerable<Member>而不是void IEnumerable<Member>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型“ IReportServerCredentials”在未引用的程序集中定义。 - type 'IReportServerCredentials' is defined in an assembly that is not referenced. 类型&#39;IAsyncOperationWithProgress &lt;,&gt;&#39;在未引用的程序集中定义。 - The type 'IAsyncOperationWithProgress<,>' is defined in an assembly that is not referenced. 引用类型'Assembly'声明它在'System.Runtime'中定义,但找不到它 - Reference to type 'Assembly' claims it is defined in 'System.Runtime', but it could not be found “组件”类型是在未引用的程序集中定义的。 您必须添加对程序集“System.ComponentModel.Primitives”的引用 - The type 'Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.Primitives' “System.Object”类型在未引用的程序集中定义。 您必须添加对程序集 .netstandard 的引用 - The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard 类型“ System.Data.Common.DbTransaction”在未引用的程序集中定义。 您必须添加对程序集的引用 - The type 'System.Data.Common.DbTransaction' is defined in an assembly that is not referenced. You must add a reference to assembly 类型“IEnumerable&lt;&gt;”是在未引用的程序集中定义的 - The type 'IEnumerable<>' is defined in an assembly that is not referenced 类型“ DbConnection”在未引用的程序集中定义。 我无法添加参考? - The type 'DbConnection' is defined in an assembly that is not referenced. I cannot add the reference? 在未引用的程序集中定义类型“ x”。 VS 2010 C# - The type “x” is defined in an assembly that is not referenced. VS 2010 C# System.IObserver&#39;1 <T0> 在未引用的程序集中定义。 您必须添加对程序集的引用 - System.IObserver'1<T0> is defined in an assembly that is not referenced. You must add a reference to assembly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM