在Powershell V5.1中..。如果我使用以下命令安装.NET NuGet包(例如:redmine-api):
Install-Package redmine-api然后如何从该包中创建一个新对象,以便在Powershell中使用?
我试过:
Add-Type -AssemblyName Redmine.Net.Api
# OUTPUT: Add-Type : Cannot add type. The assembly 'Redmine.Net.Api' could not be found.
[reflection.assembly]::LoadWithPartialName("Redmine.Net.Api")
# OUTPUT: (no ouput)
$rdm = New-Object Redmine.Net.Api
# OUTPUT: New-Object : Cannot find type [Redmine.Net.Api]: verify that the assembly containing this type is loaded.发布于 2017-01-26 10:51:06
正如@Matthew指出的那样,它没有工作,因为我试图将命名空间加载到对象中。正确的方法是:
[reflection.assembly]::LoadWithPartialName("Redmine.Net.Api")
$rdm = New-Object Redmine.Net.Api.RedmineManager查看包的文档,程序集名称与using Redmine.Net.Api相关,对象名称与C#源代码中的new RedmineManager(host, apiKey)相关。
https://serverfault.com/questions/828318
复制相似问题