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

370
Visualizações
How to build a .NET Windows library using a COM reference, that could target either .NET Framework 4.8 and .NET 6?

Context

Using an API delivered as a COM reference, the goal is to build Windows-only applications targeting either .NET Framework 4.8 or .NET 6.

A library of helper methods around the API will be written and be reused across projects.

Question

What would be the best way to build this library, so that it could be used either in a .NET Framework 4.8 project or in a .NET 6 project?

So far here are the options I thought about:

  • Using .NET Standard: Impossible since it is not possible to reference a COM dll in a .NET Standard project. The reason is that a .NET Standard library should warrant that it could run on every compatible target, which includes non-Windows target, on which COM makes no sense. Or am I wrong?
  • The obvious one: Making two libraries, one targeting .NET Framework 4.8 and the other .NET 6. Copy/Paste code from one to the other. A little bit nasty, but it works.
  • A variation: Making two libraries, again, but this time having the second library simply reference the source files of the first one, using Visual Studio feature Add as Link. You still need to perform the adding operation in the second project every time you create a new file in the first one, so it is not fully automated.
  • Another variation: Making two libraries, one targeting .NET Framework 4.8 and the other .NET 6. But this time have a script (or a service, etc...) automatically mirror the source files from one project to the other.

Is there any better way to achieve this? Did I miss something?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I have a couple of projects that use COMReference. For multi-targeting different frameworks for these projects, I use the following, in my csproj file:

<TargetFrameworks>net472;net5.0-windows;net6.0-windows</TargetFrameworks>

net472, as well as, net48 is supposedly equivalent with netstandard2.0.

if going through nuget, nuget will attempt to match the correct dll out of the multi-pack bundle with the corresponding framework of the host application.

over 4 years ago · Santiago Trujillo Relatório
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