C# CSharpCodeProvider“找不到元数据文件”正在使用Mono编译插件代码

C# CSharpCodeProvider“找不到元数据文件”正在使用Mono编译插件代码,c#,.net,mono,C#,.net,Mono,我在XML文件中有一些代码,我在应用程序运行时加载并编译这些代码 这在Windows上运行良好,但在Mono下我会遇到程序集引用错误。下面是有问题的检查代码: public static bool CompileSpell(Spell spell) { CSharpCodeProvider prov = new CSharpCodeProvider(); CompilerParameters cp = new CompilerParameters(

我在XML文件中有一些代码,我在应用程序运行时加载并编译这些代码

这在Windows上运行良好,但在Mono下我会遇到程序集引用错误。下面是有问题的检查代码:

public static bool CompileSpell(Spell spell)
{
            CSharpCodeProvider prov = new CSharpCodeProvider();
            CompilerParameters cp = new CompilerParameters();
            cp.GenerateExecutable = true;
            cp.GenerateInMemory = true;
            cp.ReferencedAssemblies.Add("system.dll");
            cp.ReferencedAssemblies.Add("system.xml.dll");
            cp.ReferencedAssemblies.Add("BasternaeMud.dll");
            cp.ReferencedAssemblies.Add("ZoneData.dll");

            Log.Trace("Compiling spell '" + spell.Name + "'.");

            StringBuilder sb = new StringBuilder();
            int idx = spell.FileName.IndexOf('.');
            string file = spell.FileName;
            if (idx > 0)
            {
                file = spell.FileName.Substring(0, idx);
            }
            int lines = GenerateWithMain(sb, spell.Code, "BasternaeMud");

            CompilerResults cr = prov.CompileAssemblyFromSource(cp,sb.ToString());
            ....
我在编译器结果中得到的具体错误有:

cannot find metadata file 'system.dll' at line 0 column 0.
cannot find metadata file 'system.xml.dll' at line 0 column 0.
Mono显然不喜欢我将引用的程序集添加到为system.xml和system.xml.dll编译的代码中的方式。其他两个程序集添加得很好,这并不奇怪,因为它们是编译器实际执行的代码,并且存在于可执行目录中

你知道我需要做什么来解决这个问题吗


也许我可以将这些dll放在可执行目录中,但这感觉像是一个愚蠢的想法。

我不知道您是否在Linux上运行,但您可能希望尝试正确地将dll名称大写,因为Linux区分大小写:

System.dll
System.Xml.dll

我不知道您是否在Linux上运行,但您可能希望尝试正确地大写dll名称,因为Linux区分大小写:

System.dll
System.Xml.dll

完美的我不知道为什么我会认为这些程序集不区分大小写,但这确实奏效了。谢谢,太好了!我不知道为什么我会认为这些程序集不区分大小写,但这确实奏效了。非常感谢。