Comments (5)
Yeah I see. So the Unity engine loads your DLL in a special way that the entry assembly is null
. I can change that to the Interpreter
assembly as well. But then the contract of where to load .init.ss
changes - just a little bit - from loading it from the application directory to the directory where the Interpreter
assembly resides. I think this is OK as in most of the cases they are the same, plus it works for this special scenario.
I'll push a change to this.
Thanks for testing it!
from schemy.
Hi thanks for reporting. Could you post the detail error message and exception? I want to know why in Unity it fails to load resource files.
The reason I go with resource files is because it's embedded into the assembly and thus easier to use and deploy.
As you said, I think it's good to provide an alternative to load init.ss
. But I just want to understand the whole picture before going deeper.
from schemy.
I got follow error on Interpreter constructor.
NullReferenceException: Object reference not set to an instance of an object
Schemy.Interpreter+<GetInitializeFiles>d__5.MoveNext () (at <f7e0787f1e18405798aa9ba277be8de6>:0)
Schemy.Interpreter..ctor (System.Collections.Generic.IEnumerable`1[T] environmentInitializers, Schemy.IFileSystemAccessor fsAccessor) (at <f7e0787f1e18405798aa9ba277be8de6>:0)
main.Start () (at Assets/main.cs:24)
here is code what i used
void Start ()
{
string inputString = "(define A 10)";
var names = Assembly.GetExecutingAssembly().GetManifestResourceNames() ;
foreach (string s in names)
{
Debug.Log(s);
}
Debug.Log(names.Length);
names.Length -> 0
24 line-> Interpreter interpreter = new Interpreter();
using (TextReader tr = new StringReader(inputString))
{
Interpreter.EvaluationResult result = interpreter.Evaluate(tr);
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}
Debug.Log(result.Result);
}
using (TextReader tr = new StringReader("A"))
{
Interpreter.EvaluationResult result = interpreter.Evaluate(tr);
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}
Debug.Log(result.Result);
}
}
from schemy.
This is strange. But if you try changing
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("init.ss"))
to
using (Stream stream = typeof(Interpreter).Assembly.GetManifestResourceStream("init.ss"))
I wonder if that solves the problem. Is it possible for you to try and confirm that?
diff --git a/src/schemy/Schemy.cs b/src/schemy/Schemy.cs
index 668752e..c583849 100644
--- a/src/schemy/Schemy.cs
+++ b/src/schemy/Schemy.cs
@@ -51,7 +51,7 @@ namespace Schemy
private IEnumerable<TextReader> GetInitializeFiles()
{
- using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("init.ss"))
+ using (Stream stream = typeof(Interpreter).Assembly.GetManifestResourceStream("init.ss"))
using (StreamReader reader = new StreamReader(stream))
{
yield return reader;
from schemy.
yea, that's the problem.
yea that problem caused by Assembly.GetEntryAssembly() == null
It's work on Editor. I will build test on unity3d android/ios.
using (Stream stream = typeof(Interpreter).Assembly.GetManifestResourceStream("init.ss"))
but, another line also need to change
string initFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), ".init.ss");
to using typeof(Interpreter).Assembly
NullReferenceException: Object reference not set to an instance of an object
Schemy.Interpreter+<GetInitializeFiles>d__5.MoveNext () (at C:/_testroom/schemy/src/schemy/Schemy.cs:60)
Schemy.Interpreter..ctor (System.Collections.Generic.IEnumerable`1[T] environmentInitializers, Schemy.IFileSystemAccessor fsAccessor) (at C:/_testroom/schemy/src/schemy/Schemy.cs:46)
main.Start () (at Assets/main.cs:24)
from schemy.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schemy.