Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

.Net 4.6 target issue

Discussion in 'Experimental Scripting Previews' started by tomerpeledNG, Jul 14, 2017.

  1. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    I've updated the player settings API to be 4.6 as documented.
    But my project is still targeting 3.5.

    I also tried to manually update the csproj to 4.6
    But after unity was opened it overrided it again to 3.5.

    Notice that I've update the Visual Studio Tools For Unity to the latest version (3.1.0.0)

    Anything I'm missing?
    Is this a known bug? If so, is there a workaround?

    Thanks,
    Tomer
     
    Last edited: Jul 14, 2017
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Which code editor are you using? I think that Visual Studio with VSTU (version 3.1 or later) is the only one that works properly with 2017.1.
     
  3. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    I solved it by updating visual studio with the latest update...

    Now I'm encountring with the following error message (Although the app seems to play well):

    TypeLoadException: Could not resolve type with token 0100001b
    System.Reflection.MonoMethodInfo.GetMethodInfo (System.IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:67)
    System.Reflection.MonoMethod.GetPseudoCustomAttributes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:405)
    System.MonoCustomAttrs.GetPseudoCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MonoCustomAttrs.cs:77)
    System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MonoCustomAttrs.cs:320)
    System.Reflection.MonoMethod.IsDefined (System.Type attributeType, System.Boolean inherit) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:386)
    UnityEditor.Build.BuildPipelineInterfaces.ValidateMethod[T] (System.Reflection.MethodInfo method, System.Type[] expectedArguments) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:214)
    UnityEditor.Build.BuildPipelineInterfaces.InitializeBuildCallbacks (UnityEditor.Build.BuildPipelineInterfaces+BuildCallbacks findFlags) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:190)
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I've not see this error before. Can you submit a bug report and include this project?
     
  5. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    Actually the error was moved right now. I've deleted the previous temp and library project and re-opened Unity and it seems to help....

    Now, I'm getting another error :)
    When building to Android using IL2CPP.

    I'm getting the following exception:
    message:ExecutionEngineException: Attempting to call method 'System.Reflection.MonoProperty::GetterAdapterFrame' for which no ahead of time (AOT) code was generated.
    TargetInvocationException: Exception has been thrown by the target of an invocation.


    Saw, this old post:
    https://forum.unity3d.com/threads/u...m-reflection-monoproperty-getteradapt.332335/

    And someone said it happens to him now with the 2017.1 version.
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Ok, this makes more sense. There must have been cached data around from the old Mono runtime, which caused the first error.

    Indeed, the GetterAdapterFrame issue is a known bug. We have a bug report for it, so hopefully it will be addressed soon.
     
  7. tomerpeled

    tomerpeled

    Joined:
    Jan 17, 2017
    Posts:
    1
    Any work around till then?
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I only know about the one listed in the thread you linked. I'm not familiar enough with the problem yet to understand any others.
     
  9. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    OK, BTW the error is related to some reflection code that I'm doing.
    Using PropertyInfo and it's GetValue method (The GetValue fails with the mentioned error).

    I have a code which go over an object properties and write it to log.
    Do you know of any workaorund which can work?

    BTW, this code works with mono and it used to work with Unity subset for .Net 3.5 (mono and il2cpp).
     
    Last edited: Jul 15, 2017
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'm not aware of any other work arounds.

    It makes sense that this code works with Mono, as Mono is using a JIT, and this code only has problems with AOT cases. In addition, we had corrected the class libraries in .NET 3.5 for this case, so it works there.