문제

따라서 (겉보기에는) 파란색에서 내 프로젝트가 컴파일러 경고 1685를 얻기 시작합니다.

사전 정의 된 유형 'system.runtime.compilerservices.extensionAttribute'는 글로벌 별명의 여러 어셈블리에 정의되어 있습니다. 'C : Program Files Reference Assemblies Microsoft Framework V3.5 System.core.dll'의 정의 사용

당황한 나는 그 원인을 파악하기 위해 MSDN 기사를 연구했습니다. 내가 찾은 정보는 다음과 같습니다.

Visual C# 참조 : 오류 및 경고 컴파일러 경고 (레벨 1) CS1685

오류 메시지 사전 정의 된 유형 'System.Type Name'은 글로벌 별칭의 여러 어셈블리에 정의됩니다. '파일 이름'의 정의 사용

이 오류는 System.int32와 같은 사전 정의 된 시스템 유형이 두 어셈블리에서 발견 될 때 발생합니다. 이런 일이 일어날 수있는 한 가지 방법은 .net 프레임 워크 버전 1.0 및 1.1 나란히 실행하는 것과 같은 두 개의 다른 장소에서 mscorlib를 참조하는 경우입니다.

컴파일러는 어셈블리 중 하나의 정의를 사용합니다. 컴파일러는 글로벌 별칭 만 검색하며 정의 /참조 라이브러리를 검색하지 않습니다. /nostdlib를 지정한 경우 컴파일러가 객체를 검색하고 향후 객체를 찾은 파일에서 사전 정의 된 유형에 대한 모든 검색을 시작합니다.

이제 나는 정말로 내 머리를 긁고있다.

  1. .NET 프레임 워크의 두 가지 버전을 실행하지 않습니다 (2.0과 3.5를 계산하지 않는 한).

  2. 나는 나를 의심 할 수있는 기괴한 어셈블리를 언급하지 않습니다.

  3. 이 변경 사항을 촉진하는 응용 프로그램을 변경하는 것을 기억하지 못합니다.

  4. 모든 구성 요소가 .NET Framework 버전 v2.0.50727을 대상으로하는지 확인했습니다.

나는 제안이나 이것을 바로 잡는 방법에 대한 아이디어에 열려 있습니다. 나는 경고를 오류로 취급하고 그것은 나를 미치게합니다.

정말로 나에게 버그가있는 것은 내가 모른다는 것입니다. 발생합니다. 일어난 일에는 식별 가능한 원인이 있어야하며 왜 그런 일이 일어 났는지 알아야합니다. 설명 할 수 없다면 정확하게 해결할 수 없습니다. 추측은 결코 만족스럽지 않습니다.

응용 프로그램은 클래스 라이브러리와 Windows 양식 응용 프로그램으로 구성된 간단합니다.

  • AC# 클래스 라이브러리 DLL 기본 기능을 제공하는 데이터베이스 액세스를 제공합니다. 이것은 다음 구성 요소를 참조합니다.

    • 체계
    • System.core
    • System.core.data
    • System.Data
    • System.data.datasetextensions
    • System.data.oracleclient
    • System.Drawing
    • System.windows.forms
    • System.xml
    • System.xml.linq
  • AC# Windows Forms Application UI를 제공합니다. 이 응용 프로그램은 다음 구성 요소를 참조합니다.

    • 클린 코드
    • CleanCodecontrols (이 두 가지 모두 구문 편집기 지원을 제공하며 .NET 3.5에 대해 로컬로 구축됩니다).
    • Linqbridge
    • Roswell.framework (위의 클래스 라이브러리)
    • 체계
    • System.core
    • System.Data
    • System.data.datasetextensions
    • System.data.oracleclient
    • System.Deployment
    • 시스템 디자인
    • System.Drawing
    • System.windows.forms
    • System.xml
    • System.xml.linq

추가 정보가 필요하면 알려 주시면 기꺼이 제공하겠습니다.

도움이 되었습니까?

해결책

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!

다른 팁

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.

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.

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

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

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.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top