'Why is .NET Core 3.1 returning: Method not found: 'System.Object Microsoft.VisualBasic.Interaction.IIf(Boolean, System.Object, System.Object)?

I am working with a .NET Core 3.1 project and it references legacy code written in VB.NET (there's no way around this). When calling into the VB.NET library, I am hit with:

Method not found: 'System.Object Microsoft.VisualBasic.Interaction.IIf(Boolean, System.Object, System.Object)'.

Everything was working fine, nothing has changed code wise that could be causing this. There was a point in time IIf hadn't been ported over by the .NET Core team, but it's been there a while now, certainly for the lifetime of this application.

Looking through the logs, it is clear the error has been coming and going. I suspect someone had a working build while others didn't. The error is therefore dependant on whoever builds and deploys. The developer with working application is now gone and no one noticed the issue because of reasons.

I've tried:

  • Installing just about everything from the VS installer.
  • Building from VS 2019 rather than 2022 as the application was originally built with 2019.
  • Clearing build folders (via clean and manually removing bin and obj folders)
  • Ensured Microsoft.VisualBasic.Core is on the system (it's in C:\ProgramFiles\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\Microsoft.VisualBasic.Core.dll).
  • Ensuring Microsoft.VisualBasic.Core is referenced. (I can see it as part of Microsoft.NETCore.App)
  • Ensuring the VB.NET library itself builds and operates as expected.
  • Manually dumped Microsoft.VisualBasic.Core.dll in the bin directory hoping for a miracle.

Despite the reference to Microsoft.NETCore.App and the Microsoft.VisualBasic.Core assembly, it never actually gets output to the \bin folder.

Any ideas? Wasted a day head scratching.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source