NodeCanvas Forums › Support › Windows Store App
Hi Gavalakis,
I am running into problems trying to generate a Windows Store App with NodeCanvas:
1. In order to create the WSA build, I had to modify NCGetMethod, changing
1 2 3 4 5 6 7 8 9 |
foreach (MethodInfo m in methods){ if (m.Name == name){ if (m.IsPrivate && includePrivate) return m; if (m.IsPublic) return m; } } |
to
1 2 3 4 5 6 7 8 9 10 11 12 |
foreach (IEnumerable<MethodInfo> baseMethods in methods){ foreach (MethodInfo m in baseMethods){ if (m.Name == name){ if (m.IsPrivate && includePrivate) return m; if (m.IsPublic) return m; } } } return null; |
2. After making this change, when I run the build I get several errors along the lines of:
Exception: Attempt by method ‘NodeCanvas.Conditions.CheckKeyboardInput.Unity_Deserialize()’ to access method ‘NodeCanvas.Task+TaskAgent.Unity_Deserialize()’ failed.
Type: System.MethodAccessException
Module: Assembly-CSharp
InnerException: <No Data>
AdditionalInfo:<No Data>
at NodeCanvas.Conditions.CheckKeyboardInput.Unity_Deserialize()
at UnityEngine.IUnitySerializable.$Invoke0(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
(Filename: C:/BuildAgent/work/d63dfc6385190b60/Runtime/Scripting/WinRTUtility.cpp Line: 88)
MethodAccessException: Attempt by method ‘NodeCanvas.Conditions.CheckKeyboardInput.Unity_Deserialize()’ to access method ‘NodeCanvas.Task+TaskAgent.Unity_Deserialize()’ failed.
at NodeCanvas.Conditions.CheckKeyboardInput.Unity_Deserialize()
at UnityEngine.IUnitySerializable.$Invoke0(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
(Filename: TODO Line: 0)
and
A script behaviour has a different serialization layout when loading. (Read 36 bytes but expected 92 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
(Filename: C:/BuildAgent/work/d63dfc6385190b60/Runtime/Serialize/SerializedFile.cpp Line: 1170)
I’ve attached a simple test level that demonstrates the problem along with a text file with the build output.
Thanks,
Todd Heckel
For some reason the exported package was larger than the actual project size, and too large for your site. Unfortunately it doesn’t seem to accept .zip files either, what is the best way to upload a sample project?
Todd Heckel
I was able to eliminate the MethodAccessExceptions by making the TaskAgent class public, i.e. in Task.cs, line 44:
public class TaskAgent : BBVariable{
I also removed the initializer on the member (since serialization takes care of creating the object), changing
private TaskAgent taskAgent = new TaskAgent();
to just
private TaskAgent taskAgent;
Not sure why this would only affect WSA builds.
Todd
Actually it makes sense why it would only affect WSA (and WP8) builds, which use .NET instead of Mono, and the former defaults to private nested classes while the latter defaults to public.
/Todd
BTW, this was with 1.5.8. I just tried upgrading to 1.5.9b and I’m seeing quite a few build errors in WSA, all related to reflection:
AssetsNodeCanvasCoreBlackboardBlackboard.cs(87,76): error CS1928: ‘System.Type’ does not contain a definition for ‘NCGetAttribute’ and the best extension method overload ‘NodeCanvas.NCReflection.NCGetAttribute(System.Reflection.MemberInfo, System.Type, bool)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreBlackboardBlackboard.cs Line: 87)
AssetsNodeCanvasCoreBlackboardBlackboard.cs(87,76): error CS1929: Instance argument: cannot convert from ‘System.Type’ to ‘System.Reflection.MemberInfo’
(Filename: AssetsNodeCanvasCoreBlackboardBlackboard.cs Line: 87)
AssetsNodeCanvasCoreGraphGraph.cs(468,32): error CS1061: ‘System.Type’ does not contain a definition for ‘GetField’ and no extension method ‘GetField’ accepting a first argument of type ‘System.Type’ could be found (are you missing a using directive or an assembly reference?)
(Filename: AssetsNodeCanvasCoreGraphGraph.cs Line: 468)
AssetsNodeCanvasCoreGraphNode.cs(59,20): error CS1928: ‘System.Type’ does not contain a definition for ‘NCGetAttribute’ and the best extension method overload ‘NodeCanvas.NCReflection.NCGetAttribute(System.Reflection.MemberInfo, System.Type, bool)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreGraphNode.cs Line: 59)
AssetsNodeCanvasCoreGraphNode.cs(59,20): error CS1929: Instance argument: cannot convert from ‘System.Type’ to ‘System.Reflection.MemberInfo’
(Filename: AssetsNodeCanvasCoreGraphNode.cs Line: 59)
AssetsNodeCanvasCoreOtherNCReflection.cs(52,37): error CS1061: ‘System.Type’ does not contain a definition for ‘GetMethod’ and no extension method ‘GetMethod’ accepting a first argument of type ‘System.Type’ could be found (are you missing a using directive or an assembly reference?)
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 52)
AssetsNodeCanvasCoreOtherNCReflection.cs(120,28): error CS0161: ‘NodeCanvas.NCReflection.NCGetMethod(System.Type, string, bool)’: not all code paths return a value
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 120)
AssetsNodeCanvasCoreOtherNCReflection.cs(183,11): error CS1928: ‘System.Reflection.MemberInfo’ does not contain a definition for ‘GetTypeInfo’ and the best extension method overload ‘System.Reflection.IntrospectionExtensions.GetTypeInfo(System.Type)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 183)
AssetsNodeCanvasCoreOtherNCReflection.cs(183,11): error CS1929: Instance argument: cannot convert from ‘System.Reflection.MemberInfo’ to ‘System.Type’
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 183)
AssetsNodeCanvasCoreOtherNCReflection.cs(267,32): error CS1061: ‘System.Type’ does not contain a definition for ‘GetMethod’ and no extension method ‘GetMethod’ accepting a first argument of type ‘System.Type’ could be found (are you missing a using directive or an assembly reference?)
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 267)
AssetsNodeCanvasCoreOtherNCReflection.cs(277,33): error CS1928: ‘System.Reflection.ParameterInfo[]’ does not contain a definition for ‘Select’ and the best extension method overload ‘System.Linq.Enumerable.Select<TSource,TResult>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,int,TResult>)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 277)
AssetsNodeCanvasCoreOtherNCReflection.cs(277,53): error CS1503: Argument 2: cannot convert from ‘lambda expression’ to ‘System.Func<System.Reflection.ParameterInfo,int,System.Linq.Expressions.Expression>’
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 277)
AssetsNodeCanvasCoreOtherNCReflection.cs(293,33): error CS1928: ‘System.Reflection.ParameterInfo[]’ does not contain a definition for ‘Select’ and the best extension method overload ‘System.Linq.Enumerable.Select<TSource,TResult>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,int,TResult>)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 293)
AssetsNodeCanvasCoreOtherNCReflection.cs(293,53): error CS1503: Argument 2: cannot convert from ‘lambda expression’ to ‘System.Func<System.Reflection.ParameterInfo,int,System.Linq.Expressions.Expression>’
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 293)
AssetsNodeCanvasCoreOtherNCReflection.cs(315,42): error CS1061: ‘System.Type’ does not contain a definition for ‘IsValueType’ and no extension method ‘IsValueType’ accepting a first argument of type ‘System.Type’ could be found (are you missing a using directive or an assembly reference?)
(Filename: AssetsNodeCanvasCoreOtherNCReflection.cs Line: 315)
AssetsNodeCanvasCoreTasksTask.cs(145,20): error CS1928: ‘System.Type’ does not contain a definition for ‘NCGetAttribute’ and the best extension method overload ‘NodeCanvas.NCReflection.NCGetAttribute(System.Reflection.MemberInfo, System.Type, bool)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreTasksTask.cs Line: 145)
AssetsNodeCanvasCoreTasksTask.cs(145,20): error CS1929: Instance argument: cannot convert from ‘System.Type’ to ‘System.Reflection.MemberInfo’
(Filename: AssetsNodeCanvasCoreTasksTask.cs Line: 145)
AssetsNodeCanvasCoreTasksTask.cs(160,20): error CS1928: ‘System.Type’ does not contain a definition for ‘NCGetAttribute’ and the best extension method overload ‘NodeCanvas.NCReflection.NCGetAttribute(System.Reflection.MemberInfo, System.Type, bool)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreTasksTask.cs Line: 160)
AssetsNodeCanvasCoreTasksTask.cs(160,20): error CS1929: Instance argument: cannot convert from ‘System.Type’ to ‘System.Reflection.MemberInfo’
(Filename: AssetsNodeCanvasCoreTasksTask.cs Line: 160)
AssetsNodeCanvasCoreTasksTask.cs(173,20): error CS1928: ‘System.Type’ does not contain a definition for ‘NCGetAttribute’ and the best extension method overload ‘NodeCanvas.NCReflection.NCGetAttribute(System.Reflection.MemberInfo, System.Type, bool)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreTasksTask.cs Line: 173)
AssetsNodeCanvasCoreTasksTask.cs(173,20): error CS1929: Instance argument: cannot convert from ‘System.Type’ to ‘System.Reflection.MemberInfo’
(Filename: AssetsNodeCanvasCoreTasksTask.cs Line: 173)
AssetsNodeCanvasCoreTasksTask.cs(363,23): error CS1928: ‘System.Type’ does not contain a definition for ‘NCGetAttribute’ and the best extension method overload ‘NodeCanvas.NCReflection.NCGetAttribute(System.Reflection.MemberInfo, System.Type, bool)’ has some invalid arguments
(Filename: AssetsNodeCanvasCoreTasksTask.cs Line: 363)
AssetsNodeCanvasCoreTasksTask.cs(363,23): error CS1929: Instance argument: cannot convert from ‘System.Type’ to ‘System.Reflection.MemberInfo’
(Filename: AssetsNodeCanvasCoreTasksTask.cs Line: 363)
Error building Player because scripts had compiler errors
Hello,
Thanks so much for all this information as well as the fix for 1.5.8.
I really scratching my head to fix this stuff and this is really helpfull.
In 1.5.9 I changed lot of the reflection to use direct delegates instead of eg MethodInfo.Invoke, which results in much faster performance using the delegate of course. Unfortunately there are some issues with it in mobiles, so I think I will just go ahead and revert these.
Again, thanks a lot!
Cheers!
Join us on Discord: https://discord.gg/97q2Rjh
Hi Gavalakis,
I’m seeing these issues specifically building for Windows Store App (we’re not targeting Windows Phone or any other mobile) and would certainly like to retain the performance improvements if possible, so I can try to look into the build errors if it would help. Just curious, are you not able to build WSA for some reason?
Thanks,
/Todd
Hey Todd,
I am not sure how to handle the situation. I also want to reatain the performance, but of course have the package work in mobiles as well. I will need to come up with a solution.
I can’t build on those platforms cause I’m on Windows 7. Unless I am missing something 🙂
Join us on Discord: https://discord.gg/97q2Rjh