Search Unity

Hashtable Arraylist compilation error

Discussion in 'Windows' started by xstahef, Jul 25, 2013.

  1. xstahef

    xstahef

    Joined:
    Jul 3, 2012
    Posts:
    27
    Hello,

    I'm using Unity 4.2 in order to compile for Windows 8 platform. When I play th game in the editor, I have no problem, but when I launch the compilation, the compiler throw exception on all code where ArrayList or HashTable is present.

    the error is cs0246 : The type or namespace name 'ArrayList' could not be found (are you missing a using directive or an assembly reference?)

    Scripts like CombineChildren use these kind of keyword. Is it a way to replace ? Compilation has no error for win32 or webplayer. It's just for Windows 8...

    Thanks for your help
     
  2. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Metro/WP8 platforms don't support em anymore so you have to something else like List<>
     
  3. xstahef

    xstahef

    Joined:
    Jul 3, 2012
    Posts:
    27
    Thanks Ostwind.
    But I've change 'Compilation Overrides' to none in Settings and it compiles now. I cannot understand but... it works.
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    In the end you'll still need to fix those errors, otherwise you won't pass Windows App Certification, and won't able to publish your app.
     
  5. xstahef

    xstahef

    Joined:
    Jul 3, 2012
    Posts:
    27
    Ok Tomas.
    Thanks for advice.
     
  6. Ankit-Priyarup

    Ankit-Priyarup

    Joined:
    Mar 7, 2013
    Posts:
    52
    well, Same here i want to compile my android 2D game for windows 8 but in playerprefs.cs script it shows the error

    Assets\Scripts\PlayerPrefs.cs(11,18): error CS0246: The type or namespace name 'Hashtable' could not be found (are you missing a using directive or an assembly reference?)

    Please Help

    Thanks in Advance
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    As Ostwind mentioned, Hashtable class does not exist on Windows 8. You'll have to use some different data structure in your scripts.
     
  8. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    Windows phone 8 does not have Compilation Overrides settings actually. Is there any work around for this!
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    There's only one way around it: replace forbidden API calls :).
     
  10. dberroa

    dberroa

    Joined:
    Dec 16, 2012
    Posts:
    146
    So what about Unity Pro Water, which is giving the hashtable error?

    I feel like after paying $1,500 I should be able to use the water that I can only get with that version, on all platforms.
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hi,

    which version of Unity are you using? We reimplemented loads of types in Unity 4.3, including Hashtable, so the water and other standard assets will work now. I suggest using either Unity 4.3.2, or 4.3.3.
     
  12. dberroa

    dberroa

    Joined:
    Dec 16, 2012
    Posts:
    146
    Are you saying I might need to update my standard assets to get a new version of Unity Pro water?

    I'm using 4.3.2 as 4.3.3 gives compilation errors for System.Type while 4.3.2 does not. In 4.3.2 I'm getting a compile error saying Hashtables are not supported in the Pro water script. Error is something like this:

    "the type or namespace name 'Hashtable' could not be found (are you missing a using directive or an assembly reference?)"


    Everything I've said refers to Windows Store (Windows 8) apps. Everything else including windows phone works well.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    What issues are you having with 4.3.3 with System.Type? I use it fairly extensively and haven't had any issues. There are a lot of properties and methods that don't work in W8 apps as seen here: http://msdn.microsoft.com/en-us/library/System.Type(v=vs.110).aspx but regardless of whether or not it allows you to get away with it in Unity 4.3.2, using ones not supported aren't going to get past MS's test process before your app is published to the store.

    I was told 4.3.3 wrapped a lot of the old classes like ArrayList and HashTable, but I was still getting ArrayList errors in 4.3.3. Fortunately, the fix was easy. Replace all ArrayLists with List<object>.
     
  14. dberroa

    dberroa

    Joined:
    Dec 16, 2012
    Posts:
    146
    I can't get all the errors for 4.3.3 as it was holding me back so I went back to 4.3.2 but here is an example of one:

    Assets\VirtualControls\Scripts\VCPluginSettings.cs(46,24): error CS1061: 'System.Type' does not contain a definition for 'GetMember' and no extension method 'GetMember' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)

    NGUI was giving similar errors in all their scripts.

    Now 4.3.2 doesn't give the system.type errors but still won't compile cause of Unity Pro water.
     
  15. dberroa

    dberroa

    Joined:
    Dec 16, 2012
    Posts:
    146
    Hold up, I deleted the Unity Pro that I used (imported at the start of the project) and downloaded version 3.5 from the asset store and that doesn't have hastables and do not error anymore.

    So water is fixed, but now I'm getting compile errors on hashtable in some third party plugin scripts I have such as Killerwaves and soundmanagerpro.

    If this is fixed in 4.3.3 I could upgrade, but then I get the System.Type errors on everything.

    I feel like I can't win with Windows Store apps :(
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    That error is because the .NET 4.5 subset that Windows 8 store apps use doesn't support System.Type.GetMember as you can see from this page on MSDN: http://msdn.microsoft.com/en-us/library/System.Type(v=vs.110).aspx -- Every method/property that has the little green briefcase is supported in Windows 8 store apps, everything without it is not. So if you were to publish with Unity 4.3.2 because it didn't report these errors, Microsoft is going to make you go back and change it anyway when they run their tests when you submit to the store. Ultimately, you're going to have to work around those missing features in System.Type and its better that 4.3.3 is at least showing you up front instead of you having to discover this later when you try to publish.

    There are a ton of features missing from the .NET version the app store uses. Its a bit frustrating at this point because even the MS documentation on all this is not very complete. And Unity's support is only partial at this point as well with major missing features such as networking.
     
  17. dberroa

    dberroa

    Joined:
    Dec 16, 2012
    Posts:
    146

    So in terms of the plugins I guess I have to wait till the plugin developers update their code....bummer

    Alright well sorry if I caused any confusion with my questions. Thank you for your help.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    That's about the size of it. It wouldn't hurt to ask the developers to provide a Windows 8 store compatible DLL in their package.