我正在使用XNA制作一个RPG风格的游戏,现在我正在实现一个脚本引擎。
我已经跟随了一些教程来尝试让它工作。目前我从XML文件中读取以下内容:
namespace MyGame
{
public class EngagedCode : ScriptingInterface.IScriptType1
{
public string RunScript()
{
ChangeFrame( 2 );
}
}
}
在我成功将它引入项目后,我尝试使用以下代码进行编译:
Microsoft.CSharp.CSharpCodeProvider csProvider = new Microsoft.CSharp.CSharpCodeProvider();
CompilerParameters options = new CompilerParameters();
options.GenerateExecutable = false; //DLL
options.GenerateInMemory = true;
options.IncludeDebugInformation = true;
options.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
CompilerResults result = csProvider.CompileAssemblyFromSource(options, code);
然而,此时我总是遇到以下错误:
'result.CompiledAssembly' threw an exception of type 'System.IO.FileNotFoundException'
似乎系统无法找到我编译的.dll文件,但我不知道原因。我不知道如何解决这个错误。有人有什么建议吗?