如何在 PowerShell 中使用 HTML Tidy .NET DLL 包装器?
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 DocumentClass 类型创建文档,例如:
C# 在使用互操作程序集和 IIRC 时发挥了一些作用,其中之一是采用“Foo”的类规范,然后创建“FooClass”的实例。
Try creating the document using the DocumentClass type e.g.:
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".