我想在Powershell中使用自定义.net库中的接口,但总是出现此错误:
fig = plt.figure(figsize=(75, 75))
plt.subplot(1,1,1,aspect='equal')
mf.dis.top.plot(contour=True, colorbar=True)
plt.title('')
plt.savefig('top_plot.png')
例如,如果我使用系统名称空间中的IComparable接口,它将正常工作。
class Logger : Systems.SysBiz.BaseTransversal.ILoggerBl
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unable to find type [Systems.SysBiz.BaseTransversal.ILoggerBl].
这是我的.net界面
[System.Reflection.Assembly]::LoadFile('MyPath\BaseTransversal.dll')
class Logger : Systems.SysBiz.BaseTransversal.ILoggerBl
{
[bool] $SendMailException = $false;
Logger()
{
}
[void] LogFatal([string] $message, [object[]] $args)
{
Write-Host $message;
}
[void] LogException([System.Exception] $ex, [string] $message, [object[]] $args)
{
Write-Host $this.FormatException($ex);
}
[void] LogError([string] $message, [object[]] $args)
{
Write-Host $message;
}
[void] LogWarning([string] $message, [object[]] $args)
{
Write-Host $message;
}
[void] LogInfo([string] $message, [object[]] $args)
{
Write-Host $message;
}
[void] LogTrace([string] $message, [object[]] $args)
{
Write-Host $message;
}
[void] LogDebug([string] $message, [object[]] $args)
{
Write-Host $message;
}
[string] FormatException([System.Exception] $ex)
{
if (!$ex)
{
return "";
}
return "<br/><b>" + $ex.Message + "</b><p>" + $ex.StackTrace + "</p><br/>" + $this.FormatException($ex.InnerException);
}
}
更新:添加了完整的powershell类代码 我也尝试在.net代码中使用空接口,但是看起来即使我的接口都是公共的,我也无法看到/使用。我错过了什么吗?
更新2:添加了确切的错误
答案 0 :(得分:0)
我遇到了同样的问题。在评估脚本之前,将处理PowerShell类。因此,在类尝试从其继承之前,第一行不会运行,因此未定义类型。一种解决方案是将类和加载移动到两个单独的脚本中。然后在构成您的入口点的第三个脚本中对它们进行点源处理。加载定义外部类型fir的脚本。然后加载定义您的类的脚本,以这种方式在第二个脚本开始评估之前导入类型。
onChildDrawOver