Author Topic: Windows Phone 8 System.IO.File::ReadAllBytes(System.String) error  (Read 15909 times)

TegTap

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
I'm running the latest version of NGUI (3.0.5), targeting WP8, and I'm getting this error in Unity:

Error building Player: Exception: Error: method `System.Byte[] System.IO.File::ReadAllBytes(System.String)` doesn't exist in target framework. It is referenced from Assembly-CSharp.dll at System.Byte[] NGUITools::Load(System.String).

Has anyone else had this problem?  If so, did you find a solution?  I have successfully built and published this exact app for iOS, Android, Blackberry, Windows 8 Store, and OSX.  This error only shows up when I try to build for WP8.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Windows Phone 8 System.IO.File::ReadAllBytes(System.String) error
« Reply #1 on: November 13, 2013, 04:34:06 PM »
That entire section is in an #ifdef block that excludes WP8. How are you getting there?

TegTap

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Re: Windows Phone 8 System.IO.File::ReadAllBytes(System.String) error
« Reply #2 on: November 13, 2013, 04:47:21 PM »
I have no idea how I'm getting there.  I haven't touched any NGUI code for this project.  Where is the #ifdef block you're referring to?

TegTap

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Re: Windows Phone 8 System.IO.File::ReadAllBytes(System.String) error
« Reply #3 on: November 13, 2013, 04:57:44 PM »
Here's the fix.  In NGUITools.cs, line 769 change

#if UNITY_WEBPLAYER || UNITY_FLASH || UNITY_METRO

to

#if UNITY_WEBPLAYER || UNITY_FLASH || UNITY_METRO || UNITY_WP8

You pointed me in the right direction when you said it was in a section that is not supposed to be accessed by WP8.  UNITY_METRO doesn't include WP8.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Windows Phone 8 System.IO.File::ReadAllBytes(System.String) error
« Reply #4 on: November 13, 2013, 08:18:15 PM »
Our lines don't match. I have a feeling you don't have 3.0.5, because all lines that use #if there have UNITY_WP8 as the last parameter.

TerraCo

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Windows Phone 8 System.IO.File::ReadAllBytes(System.String) error
« Reply #5 on: November 14, 2013, 03:37:16 AM »
I can confirm that TegTap's fix resolves the issue on 3.0.5

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Windows Phone 8 System.IO.File::ReadAllBytes(System.String) error
« Reply #6 on: November 14, 2013, 03:17:54 PM »
Either that or I added that fix in the Pro version post-3.0.5 then forgot about it, because that change is already there.

RefinedGames

  • Guest
Re: Windows Phone 8 System.IO.File::ReadAllBytes(System.String) error
« Reply #7 on: November 14, 2013, 09:14:18 PM »
I'm still on 2.6.x and had to use this to compile for WP8 (but only for Unity 4.3, works fine for Unity 4.2).
Line 769 is correct for the <3.0 versions, please don't forget us... a little difficult to upgrade mid project.  :)