System.Linq.Queryable is not an attribute class error?

自闭症网瘾萝莉.ら 提交于 2020-01-06 08:33:27

问题


I am getting an error when adding [Queryable] the error is similar like this 'System.Linq.Queryable' is not an attribute class

when I tried to add namespace before [System.Web.Http.Queryable] I got another error

The type System.Web.Http.QueryableAttribute exists in both System.Web.Http.OData.dll and System.Web.Http.dll

How to resolve this?


回答1:


As Soner Gönül said. Most probably you have two using directives in your cs file:

using System.Web;
using System.Web.Http;

both define the attribute. Either remove one of those namespaces or fully qualify your attribute either as

[System.Web.Queryable]
// or
[System.Web.Http.Queryable]

Depending what the difference is of both and what you need. You will find more help in the corresponding MSDN documentation of both.




回答2:


You have two DLL references that contain exactly the same namespace, containing a class with exactly the same name. The simplest solution is to remove one of these references from your project. If you need them both for some other reasons then the only solution I can think of is to create another project which will wrap the classes you need within other classes in a different namespace.



来源:https://stackoverflow.com/questions/21527839/system-linq-queryable-is-not-an-attribute-class-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!