C#到Powershell
我有一个程序,它使用一个叫做spreadsheetgear.DLL的DLL 在Visual Studio C#中,我执行以下操作:C#到Powershell,c#,powershell,C#,Powershell,我有一个程序,它使用一个叫做spreadsheetgear.DLL的DLL 在Visual Studio C#中,我执行以下操作: Reference the spreadsheetgear.dll SpreadsheetGear.IWorkbook workbook1 = SpreadsheetGear.Factory.GetWorkbook("C:\text.xls"); 这在C#with Visual Studio中运行良好 在Powershell中,我通过以下方式创建类似逻辑:
Reference the spreadsheetgear.dll
SpreadsheetGear.IWorkbook workbook1 =
SpreadsheetGear.Factory.GetWorkbook("C:\text.xls");
这在C#with Visual Studio中运行良好
在Powershell中,我通过以下方式创建类似逻辑:
Add-Type -Path "C:\spreadsheetgear.dll"
$workbook1 = New-Object SpreadsheetGear.Factory.GetWorkbook("c:\test.xls")
然而,Powershell给了我一个错误,说。。。。
新对象:找不到类型[SpreadsheetGear.Factory.GetWorkbook]:请确保已加载包含此类型的程序集
我做错了什么。。。请帮忙
谢谢。您不是在创建新对象,而是在调用静态方法。尝试:
[SpreadsheetGear.Factory]::GetWorkbook("c:\test.xls")
GetWorkbook
实际上是SpreadsheetGear.Factory
类型上的一种方法-错误消息非常正确。澄清-这是powershell 1还是2?[Reflection.Assembly]::1中需要加载文件。