looks like you are typing to call .net 6 from a 4.8 unit test. be sure the test/caller is a .net 6 project.
Debug Error in ".NET 6.0"
I have 1 issue.
I want to use ".NET 6.0" dll file correctly.
To speaking exactly, this following problem.
I use Visual Studio 2022, and created project. I configed followings.
(1) Project.Property."Target Framework" = .NET 6.0
(2) Project.Property."Platform Target" = x64
(3) Solution.Build."Configuration Manager".Configuration = Debug
(4) Solution.Build."Configuration Manager".Platform = Any CPU
(5) Solution.Test."Processor Architecture for AnyCPU projects" = x64
Then, I used System.Reflection.Assembly. Result, it caused error "System.Reflection.TargetInvocationException (Exception has been thrown by the target of an invocation)" and "System.TypeLoadException (Could not load type 'System.Reflection.Assembly' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKyToken=b03f5f7f11d50a3a')".
Dll file directory.
(a) .NET 6.0 : C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.7\ref\net6.0\System.Runtime.dll
(b) .NET Framework 4.8 : C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.8\mscorlib.dll
Because of the fact error dll version is 4.0.0.0, I except Visual Studio 2022 read the modules of ".NET Framework 4.8".
I don't know what's wrong.
1 additional answer
Sort by: Most helpful
-
上仲 紳介(Shinsuke KAMINAKA) 21 Reputation points
2022-07-14T04:28:15.583+00:00 Thank you for answering this issue!
This is solved.This cause is the fact that I selected project type "WPF User Control Library" incorrectly(, because I couldn't select ".NET Framework 4.8" as Target Framework). Therefore, I reselected project type "WPF User Control Library (.NET Framework)".
Originally, I shouldn't select .NET 6.0(, because Target Framework of my created API is .NET Framework 4.x).