Ambiguous references with the exact same namespace

前端 未结 11 2083
余生分开走
余生分开走 2020-12-30 18:31

The RC class is not linked to a database, it is a simple class. The class is at only one place and is not partial. The Aérochem.Domain dll project compiles just

相关标签:
11条回答
  • 2020-12-30 18:56

    I know this is a pretty old issue, but maybe this will help someone. If using c# razor in Asp.Net Core 2+, if you have this problem.

    1) Copy the content of the file to notepad.

    2) Delete the .cshtml file.

    3) Create the .cshtml file with the same name.

    4) Copy the content from notepad into the new file

    I don't know if this is just a weird bug, or a consequence of upgrading a project from Core 1.0 to 2+, but it FINALLY fixed the problem for me. This was an issue for me in both Visual Studio 2017 and 2019.

    0 讨论(0)
  • 2020-12-30 18:58

    In my case, i have referenced the proyect X inside itself. So the problem wasn't ReSharper (but it was ReSharper who added the reference...)

    0 讨论(0)
  • 2020-12-30 19:00

    For ReSharper users that, like me, don't want to delete their solution's *.suo file:

    Clear your caches via: ReSharper -> Options -> Environment -> General -> Clear Caches!

    Thanks go to AUSTX_RJL for his comment to this answer. I wanted to give his valuable info more visibility.

    0 讨论(0)
  • 2020-12-30 19:01

    I had the same problem while two packages were ambiguously referencing the same dll, and this is what worked for me:

    I have given an alias name to one of the packages (named Dapper.StrongName), by putting the following into my .csproj file:

      <Target Name="ChangeNameAlias" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
        <ItemGroup>
          <ReferencePath Condition="'%(FileName)' == 'Dapper.StrongName'">
            <Aliases>AliasName</Aliases>
          </ReferencePath>
        </ItemGroup>
      </Target>
    

    And then added the namespace as using AliasName::Dapper;

    I added a post here: Ambiguous extension methods

    See related articles:

    • extern alias (C# Reference)
    • :: operator (C# Reference)
    • C# 2.0: Using different versions of the same dll in one application
    0 讨论(0)
  • 2020-12-30 19:02

    I had this problem in a .NET standard project (I call it the host project). The namespace causing the problem was in another referenced project (which was also a .NET standard project) in the same solution.

    I did everything: clean, delete resharper cache, close soln, delete .suo, delete binaries. Nothing seemed to work.

    Then I converted the host project to .NET framework and then the problem disappeared.

    0 讨论(0)
  • 2020-12-30 19:07

    If your project structure contains more than one project under one solution, then you have to delete the content of the bin folder in every project. Doing so solved the error that i was facing.

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