c# 添加vtext.dll引用后,为什么同样的代码在控制台就会出异常呢?
下面是正常编译通过的代码:
private void Form1_Load(object sender, EventArgs e)
{
HTTSLib.TextToSpeech tts = new HTTSLib.TextToSpeech();
tts.Speak("Hello world!");
}
下面是异常情况:
未处理System.InvalidCastException
HResult=-2147467262
Message=无法将类型为“System.__ComObject”的 COM 对象强制转换为接口类型“HTTSLib.TextToSpeech”。此操作失败的原因是对 IID 为“{2398E32E-5C6E-11D1-8C65-0060081841DE}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 不支持此接口 (异常来自 HRESULT:0x80004002 (E_NOINTERFACE))。
Source=ConsoleApplication1
StackTrace:
在 ConsoleApplication1.Program.Main(String[] args) 位置 c:\Users\u\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:行号 13
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
下面是代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
HTTSLib.TextToSpeech tts = new HTTSLib.TextToSpeech();
tts.Speak("Hello world!");
}
}
}
求解答,非常感谢!