脚本/ai/Dream.boo
import CultLib
import LonelyHero
class Dream(Enemy):
pass
C#
var bc = new BooCompiler();
bc.Parameters.Input.Add(new FileInput("rsc/script/ai/" + "Dream" + ".boo"));
bc.Parameters.Pipeline = new CompileToMemory();
bc.Parameters.References.Add(Assembly.GetExecutingAssembly());
bc.Parameters.References.Add(Assembly.LoadFile(new DirectoryInfo("CultLib.dll").FullName));
bc.Parameters.References.Add(Assembly.LoadFile(new DirectoryInfo("sfmlnet-audio-2.dll").FullName));
bc.Parameters.References.Add(Assembly.LoadFile(new DirectoryInfo("sfmlnet-graphics-2.dll").FullName));
bc.Parameters.References.Add(Assembly.LoadFile(new DirectoryInfo("sfmlnet-window-2.dll").FullName));
var cc = bc.Run();
if(cc.GeneratedAssembly!=null)
{
cc.GeneratedAssembly.CreateInstance("Dream", true, BindingFlags.NonPublic, null,
new object[] {Parent, pos}, null, null);
}
else
{
foreach (var error in cc.Errors)
Console.WriteLine(error);
}
在该行bc.Parameters.References.Add(Assembly.GetExecutingAssembly());
中,我添加了包含命名空间“LonelyHero”的执行程序集。然而,错误
rsc/script/ai/Dream.boo(2, 8): BCE0021: 未找到命名空间 LonelyHero。也许您忘记添加程序集引用?
出现。
LonelyHero 应该存在,为什么会出现这个错误,我该怎么做才能解决它?
注意:在替换Assembly.GetExecutingAssmebly()
为 时Assembly.GetAssembly(typeof(Enemy))
,确保它在 LonelyHero 命名空间下添加具有类的程序集,会发生相同的错误。还与Assembly.LoadFile(new DirectoryInfo("LonelyHero.exe").FullName)
出现在 Boo 0.9.4.9 和 booxw-1203 中