BC30560: 'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'

.net, .net-4.0, asp.net

Solution

A common trick to use extension methods (for LINQ etc) in .NET 2 with the C# 3 (or above) compiler was to define your own ExtensionAttribute in the right namespace.

Now that you have upgraded to a later version of .NET you need to remove this now-redundant extra attribute. Find where it is defined in your code and expunge it. Also check for external libraries like LINQBridge - you won't need this any more.

One way to find it would be to use the object browser and search for ExtensionAttribute.

Problem

I have asp.net project (in .net 2.0) and I converted project to .net 4.0. After I built the project successfully, I launched the website on browser, it throws error as following: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30560: 'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'. Source Error: [No relevant source lines] Source File: InternalXmlHelper.vb Line: 9 ........ Please give me some idea to fix it.

Original source