I have a .NET solution that contains 10 C# projects and 2 C++/CLI projects. I have upgraded all the projects to version 5.0 from version 4.0. Used upgrade-assistant to upgrade C# projects and upgraded C++/CLI projects manually by setting Common Language Runtime Support to /clr:safe and .Net Core Target Framework to .NET 5.0.
I’m using ILRepack to merge the DLLs of all the projects:
<Target Name="PostBuild" AfterTargets="Build"> <Exec Command="$(ILRepack) /internalize /keyfile:$(SolutionDir)..keysSolutionName.snk /out:$(SolutionDir)..bin$(ConfigurationName)SolutionName.dll $(TargetDir)SolutionName.Project1.dll $(TargetDir)SolutionName.Project2.dll $(TargetDir)SolutionName.Project3.dll $(TargetDir)SolutionName.Project4.dll" /> </Target>
The C# projects get merged successfully but if I try to merge C++/CLI project DLLs, I get the below error:
Failed to load assembly
Though the file is present at the given path.
Also, the DLLs get merged successfully if I target C++/CLI projects back to .NET 4.0
Source: Windows Questions C++