【发布时间】:2020-04-21 05:05:08
【问题描述】:
我已经从
添加了参考文件“System.Speech”“程序文件 (x86)\参考 程序集\Microsoft\Framework.NETFramework\v4.5.2\System.Speech.dll"。
这是正确执行我的程序所必需的。
这是我的程序:
using System;
using System.Speech.Synthesis;
namespace ConditioningSchemas
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Initializing...");
SpeechSynthesizer synth = new SpeechSynthesizer(); // Initialize a new instance of SpeechSynthesizer.
synth.SetOutputToDefaultAudioDevice(); // Configure output to Default Device (soundcard)
synth.Speak("Dominate");
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
这是我收到的错误消息:
System.BadImageFormatException: '无法加载文件或程序集 'System.Speech,版本=4.0.0.0,文化=中性, PublicKeyToken=31bf3856ad364e35'。参考程序集不应 加载执行。它们只能在 Reflection-only 中加载 加载程序上下文。 (0x80131058)'
内部异常:BadImageFormatException:无法加载引用 执行程序集。
我在其他帖子中看到我可以删除“obj”和“bin”文件夹,然后清理解决方案,然后项目应该可以工作。我也尝试将整个解决方案迁移到一个解决方案,但程序无法正常执行。
有什么解决办法吗?
【问题讨论】:
标签: c# .net visual-studio