Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#编译器参数-找不到元数据_C#_Assemblies - Fatal编程技术网

C#编译器参数-找不到元数据

C#编译器参数-找不到元数据,c#,assemblies,C#,Assemblies,在尝试从.txt文件编译一些代码时(在运行时),我有一些代码引用正在编译的代码的程序集 它已经工作了几个月了,但是我最近不得不添加System.Speech.dll作为引用程序集之一,现在当它试图在任何文本文件中编译代码时,我遇到了一个错误 以下是错误: 找不到元数据文件“System.Speech.dll” System.Speech.dll也在项目的引用中,因此如果这可能是问题所在,则不是。另外,所有其他被引用的dll都完全正常,没有任何错误 以下是代码部分:(如果您需要更多,请评论) 如何

在尝试从.txt文件编译一些代码时(在运行时),我有一些代码引用正在编译的代码的程序集

它已经工作了几个月了,但是我最近不得不添加System.Speech.dll作为引用程序集之一,现在当它试图在任何文本文件中编译代码时,我遇到了一个错误

以下是错误:

找不到元数据文件“System.Speech.dll”

System.Speech.dll也在项目的引用中,因此如果这可能是问题所在,则不是。另外,所有其他被引用的dll都完全正常,没有任何错误

以下是代码部分:(如果您需要更多,请评论)


如何删除此错误?谢谢

我能够重现您的错误,并通过执行以下更改来解决它:

CompilerParameters options = new CompilerParameters();
        options.ReferencedAssemblies.Add("System.dll");
        options.ReferencedAssemblies.Add("System.Core.dll");
        options.ReferencedAssemblies.Add("System.Drawing.dll");
        options.ReferencedAssemblies.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Speech.dll");

当然,您需要将其更改到您的位置。

我能够重现您的错误,并通过执行以下更改来解决它:

CompilerParameters options = new CompilerParameters();
        options.ReferencedAssemblies.Add("System.dll");
        options.ReferencedAssemblies.Add("System.Core.dll");
        options.ReferencedAssemblies.Add("System.Drawing.dll");
        options.ReferencedAssemblies.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Speech.dll");

当然,您需要将其更改到您的位置。

根据注释,我会将dll添加到GAC中。 NET附带的gacutil.exe可用于向GAC添加程序集

要添加共享部件,请在命令行中输入:

gacutil.exe /i mySpeechAssembly.dll
也可以使用程序集的完整路径

options.ReferencedAssemblies.Add(@"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Speech.dll")

但是我建议不要这样做。

根据评论,我会将dll添加到GAC中。 NET附带的gacutil.exe可用于向GAC添加程序集

要添加共享部件,请在命令行中输入:

gacutil.exe /i mySpeechAssembly.dll
也可以使用程序集的完整路径

options.ReferencedAssemblies.Add(@"C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Speech.dll")

但我建议不要这样做。

是GAC中的
系统.语音吗。如果它说
Copy local=false
,它通常在GAC中。可能还有其他指标,但我现在不记得了:)是GAC中的
System.Speech
?查看项目参考。如果它说
Copy local=false
,它通常在GAC中。可能还有其他指标,但我现在真的不记得了:)