问题
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