小编Gor*_*kic的帖子

get_SynonymInfo会为某些单词抛出不足的内存异常

我有一个简单的测试程序,使用Microsoft Word Interop从Thesaurus字典中获取单词含义:

using System;
using Word = Microsoft.Office.Interop.Word;

class Program
{
    static void Main(string[] args)
    {
        string word = "elite"; // = "common";

        var app = new Word.Application();
        var synInfo = app.SynonymInfo[word, Word.WdLanguageID.wdEnglishUS];

        if (synInfo.Found && synInfo.MeaningCount > 0)
        {
            foreach (var meaning in synInfo.MeaningList as Array)
                Console.WriteLine(meaning.ToString());
        }

        // release memory and quit Word app... (see below)
    }
}
Run Code Online (Sandbox Code Playgroud)

使用Microsoft Office 2010和Microsoft Office 2013 Preview在Visual Studio 2010中使用.Net 4.0,引用Office 12 PIA.对于超过15万个不同的词,这就像一个魅力.但我注意到,对于某些词,方法get_SynonymInfo抛出异常:

Unhandled Exception: System.Runtime.InteropServices.COMException: Insufficient memory or disk space. …
Run Code Online (Sandbox Code Playgroud)

c# ms-word office-interop

12
推荐指数
1
解决办法
1270
查看次数

标签 统计

c# ×1

ms-word ×1

office-interop ×1