2

PowerShell2.0でHTMLTidy.NETラッパーを使用しようとしています。

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

どうしたの?

4

1 に答える 1

6

DocumentClassタイプを使用してドキュメントを作成してみてください。例:

$doc = new-object tidy.documentclass

C#は相互運用機能アセンブリを使用するときに魔法をかけます。IIRCの1つは、「Foo」のクラス仕様を取得して、「FooClass」のインスタンスを作成することです。

于 2009-09-28T15:51:51.900 に答える