如何在 PowerShell 中使用 HTML Tidy .NET DLL 包装器?

发布于 2024-08-06 21:55:21 字数 1826 浏览 1 评论 0原文

我正在尝试在 PowerShell 2.0 中使用 HTML Tidy .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

发生了什么事?

I'm trying to use the HTML Tidy .NET wrapper in PowerShell 2.0.

Here is a working example using C# (TestIt.cs included in the wrapper distribution):

using Tidy;
Document tdoc = new Document();

I'm doing this in PowerShell:

[Reflection.Assembly]::LoadFile("C:\Users\e-t172\Desktop\Tidy.NET\Tidy.dll")
New-Object Tidy.Document

I get the following error:

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

Additional info:

> [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

What's going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想你只要分分秒秒 2024-08-13 21:55:21

尝试使用 DocumentClass 类型创建文档,例如:

$doc = new-object tidy.documentclass

C# 在使用互操作程序集和 IIRC 时发挥了一些作用,其中之一是采用“Foo”的类规范,然后创建“FooClass”的实例。

Try creating the document using the DocumentClass type e.g.:

$doc = new-object tidy.documentclass

C# does some magic when using interop assemblies and IIRC one of those is to take a class spec of "Foo" and in turn create an instance of "FooClass".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文