C# Compiler Warning 1685

后端 未结 6 2137
甜味超标
甜味超标 2020-12-09 14:31

So, (seemingly) out of the blue, my project starts getting compiler warning 1685:

The predefined type \'System.Runtime.CompilerServices.ExtensionAtt

相关标签:
6条回答
  • 2020-12-09 14:59

    Another easy way to verify: In your code, temporarily use the class somewhere. Example:

    System.Runtime.CompilerServices.ExtensionAttribute x = null;
    

    When building, this will generate error:

    The type 'System.Runtime.CompilerServices.ExtensionAttribute' exists in both 'c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll' and .....

    And show you immediately the 2 sources causing the conflict.

    0 讨论(0)
  • 2020-12-09 14:59

    Another solution for this issue is to use a global alias for the whole assembly:

    Reference -> Properties -> Aliases -> Replace 'global' with something else

    0 讨论(0)
  • 2020-12-09 15:04

    FYI: I had the same problem and was able to resolve it by using Resharper's "Optimize References" command, and then removing all unused references. Not completely sure why that worked, but it did.

    0 讨论(0)
  • 2020-12-09 15:08

    LINQBridge makes me immediately suspicious. The entire intent of this is to provide extension attribute/methods etc for 2.0 users. If you have 3.5 (System.Core.dll), don't use LINQBridge. If you do need LINQBridge in 3.5 for some obscure reason (and I can't think of one), then you might have to use an extern alias. But I really doubt you need it!

    0 讨论(0)
  • 2020-12-09 15:19

    Marc is almost certainly correct. Here's a way to verify

    1. Open Reflector.exe
    2. Add all of Non-System assemblies
    3. F3 and search for ExtensionAttribute

    If it pops up anywhere besides System.Core then you know where it's coming from.

    0 讨论(0)
  • 2020-12-09 15:22

    Another solution for this issue => Right click project -> Properties -> Build -> Treat warnings as errors -> None

    0 讨论(0)
提交回复
热议问题