My C# assemblies currently all target .NET Core 3.1. They all use my C++/CLI assembly (call it "MySdk") that targets .NET Framework 4.8. This works fine.
Today I tried updating the C# assemblies to .NET 5.0. Suddenly, none of them even see the .NET FW 4.8 "MySdk" assembly that's already built and sitting right there. The build process gives me output like this:
> 2>------ Build started: Project: MyApp.Core, Configuration: Debug x64
> ------ 2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5):
> warning MSB3245: Could not resolve this reference. Could not locate
> the assembly "MySdk". Check to make sure the assembly exists on disk.
> If this reference is required by your code, you may get compilation
> errors.
The obvious solution is to update the C++/CLI assembly to .NET 5. And I want to do that soon, though I don't know if it's possible.
But let us suppose that's not an option right now. Is it even valid for a .NET 5 assembly to use a .NET FW 4.8 assembly? Should this work? And is there anything else I can do to make my .NET 5 assemblies see and use this thing?
The cause of my confusion turns out to be so dumb that I am embarrassed to post it. But I will in case anyone else makes the same mistake I did.
When you update a .NET Core 3.1 app to .NET 5.0, the default build output subfolder changes from "netcoreapp3.1" to "net5.0-windows". But my build script that copied the separately-built C++/CLI assembly was copying it to the old subfolder for .NET Core 3.1 ("netcoreapp3.1").
In other words, it had nothing to do with compatibility. The assembly was being copied to the wrong place
So the answer to my question is "yes".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With