我正在尝试使用MailKit dll作为Powershell中的程序集,但是没有办法。
我已经尝试过添加类型和[System.Reflection.Assembly]方法,但都没有成功。
mailkit库的链接:
https://github.com/jstedfast/MailKit
用这种方法:
$path="$HOME\.nuget\packages\mailkit\1.16.1\lib\net451\MailKit.dll"
[System.Reflection.Assembly]::LoadFile($path)
这不是在内存中引用程序集。
用这种方法:
Add-Type -Path $path
这是错误:
- Add-Type -Path $path
- ~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [Add-Type], ReflectionTypeLoadException
- FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeCommand
谢谢
丹尼尔(Daniele)
最佳答案
检查路径。对我来说,使用$MailKitDllPath
中的绝对路径就可以了:
Add-Type -Path $MailKitDllPath
$client = New-Object MailKit.Net.Smtp.SmtpClient
关于powershell - 在Powershell中将MailKit DLL作为程序集加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44587099/