Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

368
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!