Support => NGUI 3 Support => Topic started by: DevLabTech on April 07, 2014, 04:59:08 PM
Title: Type.GetMethod, MissingMethodException on Windows Phone 8 and OnClick on UIButto
Post by: DevLabTech on April 07, 2014, 04:59:08 PM
Hi guys,
I'm a new customer and I added a UIButton with a Notify that call my MainCamera public void onclick(void) Script Method.
If I play my game on wp8, when I tap my button, my application throw a MissingMethodException on Type.GetMethod(). This exception is thrown on NGUI/Scripts/Internal/EventDelegate.cs, when the execution reach
I have read that Type.GetMethod() is replaced by Type.GetTypeInfo().GetMethod(), but this work only on .NET 4.5. Unity3D is using Mono/.NET 3.5 (but inside my WP8 Build Setting, there is only .NET 2.0 or .NET 2.0 Subset (.NET 2.0 Subset is currently selected)).
How can I fix this error?
Thanks!
Dario @DevLabTechnologies
PS: Sorry for my bad english
Title: Re: Type.GetMethod, MissingMethodException on Windows Phone 8 and OnClick on UIButto
Post by: ArenMook on April 07, 2014, 11:18:26 PM
This code shouldn't even be compiling on WP8 due to the NETFX_CORE #ifdef at the top of the file. You can try replacing that line with:
Title: Re: Type.GetMethod, MissingMethodException on Windows Phone 8 and OnClick on UIButto
Post by: DevLabTech on April 08, 2014, 04:08:27 AM
Hi ArenMook, with your code, that I have added on my Assets/NGUI/Scripts/Internal/EventDelegate.cs script, when I run my WP8 solution throw the MissingMethodException.
This code is compiled by Unity inside the Assembly-CSharp.dll. When I choose Windows Phone 8 Platform inside Build Settings options, and I click on Build... button, Unity compile Assembly-CSharp.dll (it compile also NGUI source) and create a Visual Studio Windows Phone 8 Solution.
When I run on Emulator or Device (it's the same), and press my button created by UIButton NGUI Script, with a Notify, it crash.
It is like Unity (4.3.4f1), when compile for WP8 Platform, build as the define symbols REFLECTION_SUPPORT is defined.
I'm using NGUI 3.6.5 with Unity 4.3.4f1 on Windows 8.1 Pro.
Title: Re: Type.GetMethod, MissingMethodException on Windows Phone 8 and OnClick on UIButto
Post by: DevLabTech on April 08, 2014, 04:30:14 AM
Hi, to fix this problem I have commented the #define REFLECTION_SUPPORT
#if UNITY_EDITOR || !UNITY_FLASH && !NETFX_CORE
//#define REFLECTION_SUPPORT
#endif
inside EventDelegate.cs file. It need to fix the compile errors by adding "#if REFLECTION_SUPPORT" when it need.
So now it work properly.
But in your code there are some inconsistence issue, because if REFLECTION_SUPPORT is not defined, the "using System.Reflection" directive is not compiled and yo cannot refer to MethodInfo as the using is present.
I don't know if that problem is caused by unity or not, but with this workaround, now is ok.
Thanks! Dario
Title: Re: Type.GetMethod, MissingMethodException on Windows Phone 8 and OnClick on UIButto
Post by: ArenMook on April 09, 2014, 04:03:57 AM
Yup, I fixed the inconsistencies in the Pro version. Sounds like that statement should be:
Title: Re: Type.GetMethod, MissingMethodException on Windows Phone 8 and OnClick on UIButto
Post by: DevLabTech on April 09, 2014, 04:13:38 AM
Yes! But if you don't define REFLECTION_SUPPORT, you need to fix the compile errors that occurs because Unity don't compile the "using System.Reflection;" statement ;).
There is a plan for a minor release in the Standard Licence (I bought NGUI on Asset Store for 90$).
Thanks Dario
Title: Re: Type.GetMethod, MissingMethodException on Windows Phone 8 and OnClick on UIButto
Post by: ArenMook on April 09, 2014, 04:30:47 AM
I've already fixed them on Pro a few days ago. I'll find it all working in the next update which will be on the Asset Store this week.
Title: Re: Type.GetMethod, MissingMethodException on Windows Phone 8 and OnClick on UIButto
Post by: DevLabTech on April 09, 2014, 04:46:53 AM