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

'System.NotSupportedException' occurred in mscorlib.dll

Last post 1/25/2010 2:21 PM by UberGeekGames. 6 replies.
  • 7/3/2009 5:26 PM

    '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?
    "Software is never finished, it is in varying states of 'less broken'" because "If it ain't broke, it doesn't have enough features yet"

    In Playtest: Avatar Land | The MANLY Game for MANLY Men

    The signature that was too big for the 512 char limit
  • 7/3/2009 5:47 PM 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
  • 7/3/2009 5:52 PM 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...
    "Software is never finished, it is in varying states of 'less broken'" because "If it ain't broke, it doesn't have enough features yet"

    In Playtest: Avatar Land | The MANLY Game for MANLY Men

    The signature that was too big for the 512 char limit
  • 7/4/2009 11:38 AM 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...
    "Software is never finished, it is in varying states of 'less broken'" because "If it ain't broke, it doesn't have enough features yet"

    In Playtest: Avatar Land | The MANLY Game for MANLY Men

    The signature that was too big for the 512 char limit
  • 1/25/2010 1:43 PM In reply to

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

    Sorry for necro-posting this but I'm bumping into the exact same issue again, but this time I can't work around it by using a List<Matrix> because it creates garbage (which is what I'm optimizing out right now).

    Any ideas?... I'm guessing it doesn't like my using an IList for some reason, but I'm not sure why.
    "Software is never finished, it is in varying states of 'less broken'" because "If it ain't broke, it doesn't have enough features yet"

    In Playtest: Avatar Land | The MANLY Game for MANLY Men

    The signature that was too big for the 512 char limit
  • 1/25/2010 1:56 PM In reply to

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

    Have you checked the IsReadOnly flag on the IList?  It could be that you're retrieving a read-only list, in which case if you want to change it you'll be stuck creating a new list.
  • 1/25/2010 2:21 PM In reply to

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

    Thanks, I'll double check that. In the mean time I've fixed it by keeping another List<Matrix> and using it for the final bone transforms instead of the original IList:
    //old: 
    for (int i = 0; i < correctBoneTransforms.Count; i++) 
        if (!boneOffsets[i].Overwrite) 
            correctBoneTransforms[i] = correctBoneTransforms[i] * boneOffsetsMatrix[i]; 
        else 
            correctBoneTransforms[i] = boneOffsetsMatrix[i]; 
    //new: 
    for (int i = 0; i < correctBoneTransforms.Count; i++) 
        if (!boneOffsets[i].Overwrite) 
            correctBoneTransforms_Generic[i] = correctBoneTransforms[i] * boneOffsetsMatrix[i]; 
        else 
            correctBoneTransforms_Generic[i] = boneOffsetsMatrix[i]; 
     
    ... 
     
    AvatarRenderer.Draw(correctBoneTransforms_Generic, Expression); 

    "Software is never finished, it is in varying states of 'less broken'" because "If it ain't broke, it doesn't have enough features yet"

    In Playtest: Avatar Land | The MANLY Game for MANLY Men

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