Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
Alias assemblies included in the same dll

I have a NuGet package that contains a series of assemblies that unfortunately all define the same type multiple times. Removing the duplicates is currently not an option as they are a product of generation. This yields a CS0433 compilation error like the following:

error CS0433: The type 'AmbiguousType' exists in both 'Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Assembly2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

I tried to address it by adding references to alias each of the assemblies like this:

<ItemGroup>
  <PackageReference Include="MyPackage" Version="1.0.0"/>
</ItemGroup>

<ItemGroup>
    <Reference Include="Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
      <HintPath>..\packages\netstandard2.0\assembly.dll</HintPath>
      <Aliases>Assembly1</Aliases>
    </Reference>
    <Reference Include="Assembly2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
      <HintPath>..\packages\netstandard2.0\assembly.dll</HintPath>
      <Aliases>Assembly2</Aliases>
    </Reference>
</ItemGroup>

then in the C# code I added the following to define the common type:

extern alias Assembly1;
using AmbiguousType = Assembly1::AssemblyNamespace.AmbiguousType;

but now I get a CS0430 that alias Assembly1 has not been referenced.

Is it possible to resolve this or is this something that just can't be done?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda