Question

scripts/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);
}

In the line bc.Parameters.References.Add(Assembly.GetExecutingAssembly()); I add the executing assembly, which contains the namespace "LonelyHero". However, the error

rsc/script/ai/Dream.boo(2, 8): BCE0021: Namespace LonelyHero not found. maybe you forgot to add an assembly reference?

appears.

LonelyHero should exist, why does this error occur and what can I do to resolve it?

Note: Upon replacing Assembly.GetExecutingAssmebly() with Assembly.GetAssembly(typeof(Enemy)) , thus assuring it adds the assembly with a class under the LonelyHero namespace, the same error occurs. Also with Assembly.LoadFile(new DirectoryInfo("LonelyHero.exe").FullName)

Occurs in Boo 0.9.4.9 and booxw-1203

Was it helpful?

Solution

Imported namespaces in BOO need to contain at least one public type for the import to succeed; otherwise you will get the BCE0021 error, so you want to make sure the Enemy type is public (or another one).

OTHER TIPS

I don't know Boo or C# but I found someone asking a similar question on the Boo Programming Google Group. The question they were asking:

"Namespace 'Pathfinding' not found, maybe you forgot to add an assembly reference?"

Specifically they were getting this error:

I am converting some existing code I had from C# into Boo. One of my classes had a "using Pathfinding" which got converted to "import Pathfinding" by the script converter.

I get this error when trying to compile:

Assets/Script/VehicleController.boo(4,8): BCE0021: Namespace 'Pathfinding' not found, maybe you forgot to add an assembly reference?

The Pathfinding library I'm using is written in C#. Could this cause problems? Is there anything additional I need to do to make this work?

This looked like your error message and the solution someone mentioned was that you needed to put your scripts into your compilation phase earlier to ensure that they're accessible from scripts written in other languages.

This URL was cited as a reference/source for more information on script compilation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top