gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 09:50:06 24 4
gpt4 key购买 nike

我正在尝试使用 HTML Tidy .NET wrapper在 PowerShell 2.0 中。

这是一个使用 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

这是怎么回事?

最佳答案

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

$doc = new-object tidy.documentclass

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

关于.net - 如何在 PowerShell 中使用 HTML Tidy .NET DLL 包装器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1487166/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com