Search Unity

VerificationException

Discussion in 'Scripting' started by sigsom, Sep 16, 2010.

  1. sigsom

    sigsom

    Joined:
    Aug 9, 2009
    Posts:
    133
    Getting this error but I don't know what it means. Version 3.0.1F

    Code (csharp):
    1. VerificationException: Error verifying AccelerometerBehaviourScript/<Start>c__Iterator11:MoveNext (): Cannot call a non-final virtual method from an objet diferent thant the this pointer at 0x00a3
     
  2. sigsom

    sigsom

    Joined:
    Aug 9, 2009
    Posts:
    133
    Bump for answers
     
  3. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    post this in support thread if you havent done already.
     
  4. sigsom

    sigsom

    Joined:
    Aug 9, 2009
    Posts:
    133
    Can a moderator please move this thread to support so I don't have to double post.
    Thanks
     
  5. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    This might actually be a scripting question. Are you getting this error at runtime or in the editor? Do you have a script called AccelerometerBehaviourScript in your project? If so, can you post it?
     
  6. AzulValium

    AzulValium

    Joined:
    Sep 14, 2009
    Posts:
    103
    I have the same error but only if I select Web Player as Build Plataform. :S

    This is the warning http://msdn.microsoft.com/en-us/library/ms228459(VS.80).aspx, according to this, the solution is to use a helper function.

    What I still understanding is why it works in a Standalone build....Course, 'cause is unsafe code, and that is not allowed in webplayer.

    Basically my code looks like this...
    Code (csharp):
    1.  
    2. public override IEnumerator Disable() {
    3.  
    4.       yield return StartCoroutine( base.Disable() );
    5.  
    6. }
    7.  
    I did a "fake" disable function in the base class called BaseDisable, yield return StartCoroutine( BaseDisable() ). Works but still doesn't like it, hope anyone else has a solution.
     
    Last edited: Nov 9, 2010
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Thats no unsafe code as thats not possible with Unity.

    What the error tried to explain you is that you have unverifyable code (thats not the same as unsafe as unsafe is in relation to .NET <-> native unmanaged code), which for example is created through using var xxxx instead of true type declarations and alike and then calling such stuff up the inheritance chain in a more general context.
    That will not work.

    also, you can naturally not call any base function thats virtual up the inheritance chain, which given you have override there, might very well be the case here.
    If you have a real function there, leave it as real function and declare the one here as public new IEnumerator Disable() for example
     
  8. Lucas Meijer_old

    Lucas Meijer_old

    Joined:
    Apr 5, 2008
    Posts:
    436
    I'd love to take a look at this problem. It's either a bug in Mono's verifier, or it's a genuine problem with your code.
    Could you file a bug report with the exact sourcecode that is causing this failure, and ask for the bug to be assigned to me?

    Thanks, Lucas
     
  9. AzulValium

    AzulValium

    Joined:
    Sep 14, 2009
    Posts:
    103
    If you are refering to me, I just did a little example project ( http://www.megaupload.com/?d=CZBQCIBM ). If can file it if you need to, I just didn't do it 'cause wasn't sure who you are talking to :)
     
  10. Fenyx4

    Fenyx4

    Joined:
    Aug 5, 2010
    Posts:
    23
    Sorry to dig up an old thread but I had the same problem and found a solution (sorta).

    Background:
    My friend was building for an iOS. Zipped up the entire project and sent it to me. I'm on a PC. Typically when I open the project it will switch it to PC and Mac standalone but this time it switched it to Web player.

    To make the error go away I switched it to PC and Mac standalone.
     
  11. Seifer

    Seifer

    Joined:
    Apr 18, 2008
    Posts:
    18
    I have the same issue, I use coroutines and virtual methods. The project is initially created for mobile platforms and now i'm going to port it to webplayer.
    So what is the core of the issue and what a solution/workaround exists?
     
  12. AzulValium

    AzulValium

    Joined:
    Sep 14, 2009
    Posts:
    103
    Try this...

     
  13. sparrow

    sparrow

    Joined:
    May 6, 2012
    Posts:
    17
    I still get this error. I think polimorphism is not working for coroutines. I have the latest version of unity 3 installed and the error along with the grammar mistake is still there. Stack trace:

    VerificationException: Error verifying SpiderWalker/<AvoidRock>c__Iterator34:MoveNext (): Cannot call a non-final virtual method from an objet diferent thant the this pointer at 0x00d8
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)

    And code in my class that produces this is something like this:

    Code (csharp):
    1.  
    2. Class A{
    3.    public virtual IEnumerator DoSmth(){
    4. }
    5. }
    6.  
    7. Class B : Class A {
    8.  public override IEnumerator DoSmth();
    9. }
    10.  
    11. RunnCode:
    12. //The object is of actual type ClassB
    13. classA = gameObject.GetComponent<ClassA>();
    14. StartCoroutine(ClassA.DoSmth());
    15.  
     
  14. timofei7

    timofei7

    Joined:
    Nov 6, 2008
    Posts:
    5
    I'm running into this same issue. Works fine when platform is set to iOS but has this runtime error when platform is web. I actually have the classes nested 3 levels so its even more of a pain to fix with 'fake' methods. And whats up with the misspellings in the exception?

    [edit] FYI: this is with 4.0.1f2

    in my case I have:

    Code (csharp):
    1.  
    2. class A : MonoBehaviour
    3. {
    4.    public virtual Coroutine foo {  return StartCoroutine(A_DoStuff()); }
    5.    private IEnumerator A_DoStuff() { ... }
    6. }
    7. class B : A
    8. {
    9.    public override Coroutine foo { return StartCoroutine(B_DoStuff()); }
    10.    private IEnumerator B_DoStuff()
    11.    {  
    12.         yield return base.foo();
    13.         DoMoreStuff();
    14.    }
    15. }
    16.  
    17. // which is run like:
    18. // B test = new B();
    19. // test.foo;
    20.  
    21.  
    and that gives this exception. I've tried doing new rather than override/virtual and that didn't help. Not sure why the web version is different from iOS? Is this just an old bug that was left in in the web version?


    [edit] ooooooohhhhh its because the web player is a partial trust environment... and somehow there's some unverifiable code when doing this with coroutines... blarg. I guess I'll have to make my codes ugly with helper functions.
     
    Last edited: Feb 14, 2013
  15. DrShimizu

    DrShimizu

    Joined:
    Apr 13, 2011
    Posts:
    30
    I am seeing the exact same bug for the exact same reason. I thought it was my fault because the exception was misspelled, but that exception is being spit out by the run-time environment not, my own code.

    The only way I have found to deal with this is to make the base class's function an Abstract function() with no body, and a base_function() with the body i wanted.

    In the derived classes i call base_function(): instead of base.function()



     
  16. poolts

    poolts

    Joined:
    Aug 9, 2012
    Posts:
    113
    Don't mean to pull this thread back from the dead, but did this ever get fixed?
     
  17. AmazingRuss

    AmazingRuss

    Joined:
    May 25, 2008
    Posts:
    933
    Still broken in 2014.
     
  18. VesuvianPrime

    VesuvianPrime

    Joined:
    Feb 26, 2013
    Posts:
    135
    I'm working on a web application. I have a fairly deep inheritance tree and at the very bottom I have:

    Code (csharp):
    1.  
    2.     /// <summary>
    3.      ///    Gets the metadata.
    4.      /// </summary>
    5.      /// <returns>The metadata.</returns>
    6.      public abstract IEnumerable<BaseMetadata> GetMetadata();
    7.      
    8.      /// <summary>
    9.      ///  Calls update on metadata.
    10.      /// </summary>
    11.      private void UpdateMetadata()
    12.      {
    13.        foreach (BaseMetadata item in GetMetadata())
    14.          item.Update();
    15.      }
    16.  
    This has caused Unity to throw the error:

    VerificationException: Error verifying Assets.Scripts.Designs.Concrete.Menus.Forms.LoginMenuDesign/<GetMetadata>c__Iterator16:MoveNext (): Cannot call a non-final virtual method from an objet diferent thant the this pointer at 0x003a

    It's disheartening to see the typo hasn't been corrected in 4 years, let alone the error itself.

    This also suggests the error isn't unique to coroutines.
     
  19. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    I just got this same funnily spelled exception in the Editor scripts, and only with the Web Player as target. It has something to do with virtual iterator methods, and not with the coroutines only. Anyone knows of some workaround?
     
  20. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    It turned out calling a virtual function using the base keyword inside the method body of an iterator or anonymous function is not allowed in partial trust environment, such as in Web Player. I was calling the base implementation from a virtual iterator and fortunately that call was unnecessary :p so I just removed it and it works fine now.
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I ran into this situation twice, two different scenarios:

    1) Webplayer throws an exception when a class inherits from a base class and defines a protected child class which inherits from a protected child of the base class and the constructor is called: http://forum.unity3d.com/threads/webplayer-inheritance-bug.256169/

    2) Private nested child classes trying to access a method in a private class declared in the parent. Again, webplayer-only problem. Band-aid "solution" - make the private class declared in the parent internal.
     
    mog-mog-mog likes this.