如何使用PowerShell中的HTML整洁.NET的DLL的包装? [英] How to use the HTML Tidy .NET DLL wrapper in PowerShell?
本文介绍了如何使用PowerShell中的HTML整洁.NET的DLL的包装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用 HTML在PowerShell中整洁.NET包装 2.0。
下面是使用C#(包含在包装分配TestIt.cs)工作的例子:
Here is a working example using C# (TestIt.cs included in the wrapper distribution):
using Tidy;
Document tdoc = new Document();
我在做这在PowerShell中:
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
附加信息:
> [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?
推荐答案
尝试创建使用的DocumentClass类型,例如文档:
Try creating the document using the DocumentClass type e.g.:
$doc = new-object tidy.documentclass
使用互操作组件和IIRC当其中之一是采取轮流的富和一类规范创建FooClass实例
C#做了一些魔法。
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".
这篇关于如何使用PowerShell中的HTML整洁.NET的DLL的包装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文