XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

'System.NotSupportedException' occurred in mscorlib.dll

Last post 04/07/2009 11:38 by UberGeekGames. 3 replies.
  • 03/07/2009 17:26

    'System.NotSupportedException' occurred in mscorlib.dll

    I ran into a very strange problem today.

    I've been doing some work on my AvatarWrapper class, and have been toying with the idea of allowing you to programmatically set the matrix for each bone. So far it works great on the PC, but on the Xbox I get this exception:

    Output window:

    A first chance exception of type 'System.NotSupportedException' occurred in mscorlib.dll
    An unhandled exception of type 'System.NotSupportedException' occurred in mscorlib.dll

    Additional information: NotSupportedException


    on this seemingly harmless chunk of code:
            void AddBoneOffsetsToMatrix(IList<Matrix> BoneTransforms) 
            { 
                for (int i = 0; i < boneOffsets.Length; i++) 
                { 
                    BoneTransforms[i] *= boneOffsets[i].Transform; 
                    //if (!boneOffsets[i].Keep) 
                      //  boneOffsets[i].Transform = Matrix.Identity; 
                } 
            } 

    This method is called every frame in the draw method, and it loops through all of the BoneOffsets and applies them to the corresponding bone. BoneOffset is a simple class with two variables: Keep and Transform. Transform is self explanitory, and Keep is a bool that is used to determine whether to only keep the transform for that frame.

    If I leave the keep-checking code in there, it crashes with the exception on the if(!boneOffsets[i].Keep) line. By commenting it out I delay the crash to the i++ portion of the loop. It's always after the first line of that loop, apparently, and is always on the first object of the loop.

    If I take out the call to this method, then it runs fine on the Xbox. But if I do that then I won't have this cool functionality to set the bone positions manually.

    Any ideas?
    "No programmer can pick up a TV remote without thinking what it would take to add a stun gun. [...] Their motto is 'if it ain't broke, it doesn't have enough features yet'" - Scott Adams, The Dilbert Principle

    The signature that was too big for the 512 char limit
  • 03/07/2009 17:47 In reply to

    Re: 'System.NotSupportedException' occurred in mscorlib.dll

    What is the length of BoneTransforms?

    Also, as Matrix is a value type, and IList<> is an interface, try doing a real assignment:

    BoneTransforms[i] = BoneTransforms[i] * boneOffsets[i].Transform;


    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 03/07/2009 17:52 In reply to

    Re: 'System.NotSupportedException' occurred in mscorlib.dll

    Both BoneTransforms and boneOffsets have 71 items in them.

    Doing a real assignment makes no difference either. :-(

    I forgot to mention that I had done some Bing searches on this before posting, and the only topic I came up with had to do with using reflection on the Xbox and the error being thrown since the command wasn't supported on the Xbox. No idea why anything in that method wouldn't be supported...
    "No programmer can pick up a TV remote without thinking what it would take to add a stun gun. [...] Their motto is 'if it ain't broke, it doesn't have enough features yet'" - Scott Adams, The Dilbert Principle

    The signature that was too big for the 512 char limit
  • 04/07/2009 11:38 In reply to

    Re: 'System.NotSupportedException' occurred in mscorlib.dll

    I don't know how or why but I got it working. Instead of having it in it's own method I put this into the Draw loop:
                IList<Matrix> correctBoneTransforms = GetCurrentBoneTransforms(); 
     
                List<Matrix> foo = correctBoneTransforms.ToList(); 
     
                //what I previously did 
                //AddBoneOffsetsToMatrix(correctBoneTransforms); 
                for (int i = 0; i < boneOffsets.Length; i++) 
                { 
                    //same error with this line 
                    //correctBoneTransforms[i] = correctBoneTransforms[i] * boneOffsets[i].Transform; 
                    //this works (?!?!?!!) 
                    foo[i] = foo[i] * boneOffsets[i].Transform; 
                    if (!boneOffsets[i].Keep) 
                      boneOffsets[i].Transform = Matrix.Identity; 
                } 
     
                correctBoneTransforms = foo; 

    For some reason using a List<Matrix> works but an IList<Matrix> doesn't.

    If you listen closely, you can hear the X-Files theme playing softly in the distance...
    "No programmer can pick up a TV remote without thinking what it would take to add a stun gun. [...] Their motto is 'if it ain't broke, it doesn't have enough features yet'" - Scott Adams, The Dilbert Principle

    The signature that was too big for the 512 char limit
Page 1 of 1 (4 items) Previous Next