2
我試圖在PowerShell 2.0中使用HTML Tidy .NET wrapper。如何在PowerShell中使用HTML Tidy .NET DLL封裝器?
下面是一個使用C#的工作示例(包含在包裝分發TestIt.cs):
using Tidy;
Document tdoc = new Document();
我這樣做是在PowerShell中:
[Reflection.Assembly]::LoadFile("C:\Users\e-t172\Desktop\Tidy.NET\Tidy.dll")
New-Object Tidy.Document
我得到以下錯誤:
New-Object : Constructor not found. Cannot find an appropriate constructor for type Tidy.Document.
At line:1 char:11
+ New-Object <<<< Tidy.Document
+ CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand
附加信息:
> [Reflection.Assembly]::LoadFile("C:\Users\e-t172\Desktop\Tidy.NET\Tidy.dll").getTypes()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False ITidyDocumentEvents
True True TidyReportLevel System.Enum
True True __MIDL_ITidyDocument_0008 System.Enum
True False DocumentClass System.__ComObject
True False ITidyDocumentEvents_Event
True True ITidyDocumentEvents_OnMessageEventHan... System.MulticastDelegate
True False Document
True False ITidyDocument
True True TidyOptionId System.Enum
True True __MIDL_ITidyDocument_0002 System.Enum
False False ITidyDocumentEvents_SinkHelper System.Object
False False ITidyDocumentEvents_EventProvider System.Object
發生了什麼事?
起初我以爲這不起作用......然後我意識到我試圖將32位DLL加載到64位Powershell會話中......我切換到32位PowerShell會話,它工作正常! – 2009-09-28 17:09:32