-1

I am developing a class library in .NET Standard 2.0 that should control some other application using Keystrokes. I need to write the library in .NET Standard 2.0 since I have two client applications that will be using the library, one in .NET Framework 4.8 and one in .NET 5, which both support System.Windows.Forms.SendKeys.

What would be the right approach to solve this problem?

fwinterl
  • 85
  • 1
  • 7

1 Answers1

0

If somehow you must (and it's really hard to get here), use reflection to locate class System.Windows.Forms.SendKeys and invoke the call.

Most likely, you're better off making a build for net40 (or .net48 it probably doesn't matter which) and netcoreapp3.0 using <targetframeworks>. It would look like so

     <propertygroup>
          ...
          <targetframeworks>netcoreapp3.0;net40</targetframeworks>
     </propertygroup>

And the callers pick up the right dll and it works.

Now for the hard part; you can still make a reference dll targeting netstandard2.0 with no implementation and derived packages can still resolve; but the ultimate executable needs to be one of those two (or newer) or it won't run.

Joshua
  • 40,822
  • 8
  • 72
  • 132