脚本/ AI/Dream.boo
import CultLib
import LonelyHero
class Dream(Enemy):
pass
Run Code Online (Sandbox Code Playgroud)
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);
}
Run Code Online (Sandbox Code Playgroud)
在该行中,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中
当我尝试在Visual Studio 2010中发布XNA项目时,我收到以下错误.
错误1发布失败,出现以下错误:无法将"System .__ ComObject"类型的COM对象强制转换为接口类型"Microsoft.VisualStudio.OLE.Interop.IServiceProvider".此操作失败,因为由于以下错误,对IID为"{6D5140C1-7436-11CE-8034-00AA006009FA}"的接口的COM组件的QueryInterface调用失败:不支持此类接口(HRESULT异常:0x80004002(E_NOINTERFACE)) .1 1小行星
我已经尝试过注册actxprxy.dll,ieproxy.dll正如其他人所建议的那样,但我仍然会遇到这个错误.
我用一个空白的XNA游戏模板以及一个完整的XNA游戏得到了这个错误.
我能够很好地构建和调试相同的项目.
sealed public class HMethod
{
public int Calc(string Method, int X1, int X2, int Y1, int Y2)
{
MethodInfo HMethodInfo = this.GetType().GetMethod(Method);
return (int)HMethodInfo.Invoke(
this,
new object[4] { X1, X2, Y1, Y2 }
);
}
int ManhattanH(int X1, int X2, int Y1, int Y2)
{
//Blah
}
int LineH(int X1, int X2, int Y1, int Y2)
{
//Blah
}
//Other Heuristics
}
Run Code Online (Sandbox Code Playgroud)
调用new HMethod().Calc("ManhattanH". X1, X2, Y1, Y2)HMethodInfo时为null.创建一个空引用Exception.它应该调用通过文本传递的方法(从文本文件中获取)
已解决:方法是私有的.
码:
List<Item> Contents = ObjectHandler.player.Contents.ToList<Item>() //Was HashTable
List<int> IDS = new List<int>(); //Holds Item IDs for later counting
foreach (Item I in Contents)
{
IDS.Add(I.ID); // Add ID to IDS
}
List<Item> newContents = Contents;
foreach (Item I in Contents)
{
if (IDS.Contains(I.ID)) //Check if the ID has already been used in Contents
{
newContents.Remove(I); //Remove it
}
}
Contents = newContents;
Run Code Online (Sandbox Code Playgroud)
此代码段应准备用于以后计数的ID列表,并从项列表中删除重复项.但是,只要内容中存在项目,我就会收到InvalidOperationException.我很确定我没有修改内容,foreach正在循环,因此我的困惑.有人可以向我解释一下吗?谢谢.
c# ×4
boo ×1
collections ×1
dynamic ×1
embed ×1
list ×1
methodinfo ×1
object ×1
publishing ×1
reflection ×1
xna ×1