1

I have versions 2.15 of Mailkit and MimeKit. Mimekit is dependent on System.Buffers 4.5.1. When running the code through VSCode there is no problem. But in Powershell Desktop it does not work because it is looking for System.Buffers 4.0.2.0 (which is not even available on nuget). One odd thing on top of this is that it still works in VSCode when I comment out the line to add the System.Buffers.dll, maybe this is a clue.

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"

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."```

jflener
  • 11
  • 1
  • Is "Powershell Desktop" Powershell.exe? The version number you are giving are .NET framework version numbers. PS 4, 5, and 5.1 run .NET 4.5.1 by default but that can be changed. Do not edit the .config file. – Aaron Oct 28 '21 at 00:23
  • Your error says that the file "C:\Program Files\PackageManagement\Nuget\Packages\system.buffers\4.5.1\lib\netstandard2.0\System.Buffers.dll" does not exist on your computer. Look for it. – Aaron Oct 28 '21 at 00:26
  • @Aaron Yes, powershell.exe. The does indeed exist. I don't understand your comment because it says it could not load 4.0.2.0. It is not even trying to load 4.5.1. And like I said, I can comment out that line and somehow it is still working in VS Code. I guess that means there is some default location it is finding it but then why wouldn't powershell.exe find it? $psmodulepath and $psversiontable are identical between powershell.exe and vscode. – jflener Oct 28 '21 at 15:07
  • 1
    I've been able to workaround this using the net46 folder for these three dll files instead of netstandard2.0 and it is working now. – jflener Oct 28 '21 at 23:06
  • Only PowerShell 7.x will work with netstandard by default. – jstedfast Nov 01 '21 at 14:41

0 Answers0