相关疑难解决方法(0)

如何在F#中创建COM对象

我需要IMessage接口.在C#我可以写

CDO.Message oMsg = new CDO.Message(); // ok
Run Code Online (Sandbox Code Playgroud)

但是当我尝试在F#中这样做时

let oMsg = new CDO.Message()
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息:

'new'不能用于接口类型.考虑使用对象表达式'{new ... with ...}'.

如何解决这个问题呢?

com f#

8
推荐指数
1
解决办法
487
查看次数

.net文件用mshtml写

我使用mshtml进行html解析.(版本7.0.3300.0,C:\ Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll).

HTMLDocumentClass有一个write方法,所以我使用它,但它引发了与ErrorCode的ComException:-2147352571和消息:类型不匹配.它是什么原因?如果不使用HTMLDocumentClass的write方法,他们为什么定义?

    HTMLDocumentClass getHTMLDocument(string html)
    {
        HTMLDocumentClass doc = new HTMLDocumentClass();

        doc.write(new object[] { html }); // raises exception
        doc.close();

        return doc;
    }

    HTMLDocumentClass getHTMLDocument2(string html)
    {
        HTMLDocumentClass doc = new HTMLDocumentClass();
        IHTMLDocument2 doc2 = (IHTMLDocument2)doc;
        doc2.write(new object[] { html });
        doc2.close();

        return doc;
    }
Run Code Online (Sandbox Code Playgroud)

.net c# document mshtml

4
推荐指数
1
解决办法
4930
查看次数

标签 统计

.net ×1

c# ×1

com ×1

document ×1

f# ×1

mshtml ×1