VS Code vs Powershell loading different versions of System.Buffers

Using these lines in my script

        Add-Type -Path "C:\Program Files\PackageManagement\NuGet\Packages\Portable.BouncyCastle.1.8.10\lib\netstandard2.0\BouncyCastle.Crypto.dll"
        Add-Type -Path "C:\Program Files\PackageManagement\NuGet\Packages\system.buffers\4.5.1\lib\netstandard2.0\System.Buffers.dll"
        Add-Type -Path "C:\Program Files\PackageManagement\NuGet\Packages\mimekit\2.15.0\lib\netstandard2.0\MimeKit.dll"
        Add-Type -Path "C:\Program Files\PackageManagement\NuGet\Packages\mailkit\2.15.0\lib\netstandard2.0\MailKit.dll"

This works in VS Code, and on one server it works directly in PS. But on another server I get this error:
Exception calling “Send” with “1” argument(s): “Could not load file or assembly ‘System.Buffers, Version=4.0.2.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The system cannot find the file
specified.”

What version of PowerShell are you running in each case? Check $PSVersionTable in both sessions to ensure you are using the same version.

Thanks for the reply swsamwa. The version and module location variables were the same. It turned out to be some conflict with .net versions. I switched from the netstandard2.0 folder to the net46 folder and it is now working.