views:

12921

answers:

2

I have a Silverlight application that retreives a list of serializable classes. In these classes there are other serializable classes some of which are also in a list. The thing is everything works fine until I fill one of the list of serializable classes that causes the silverlight application to throw the exception "The remote server returned an error: NotFound"

This is the code that fills the class (Don't be Intimidated by the large amount of code it's just filling the class with information):

  private SCharacter getSCharacter(Character userCharacter)
        {
            var iqcb = userCharacter.CharacterBodies;
            var iqcs = userCharacter.CharacterStats;
            var iqgs = userCharacter.CharacterSettings;
            var iqcp = userCharacter.CharacterPoints;
            var iqcproj = userCharacter.CharacterProjectiles;

            var currChar = 
                new SCharacter 
                {
                    characterID = userCharacter.characterID,
                    characterName = userCharacter.characterName,
                    characterClassID = userCharacter.characterClassID,
                    userUsername = userCharacter.userUsername
                };
            foreach (var cb in iqcb)
            {
                var scb = new SCharacterBody();
                scb.body.bodyId = cb.bodyId;
                scb.body.bodyName = cb.Body.bodyName;
                scb.bodyPart.bodyPartId = cb.BodyPart.bodyPartId;
                scb.bodyPart.bodyPartName = cb.BodyPart.bodyPartName;
                currChar.characterBodyList.Add(scb);
            }
            foreach (var cs in iqcs)
            {
                var scs = 
                    new SCharacterStat 
                    { 
                          characterID = cs.characterID,
                          statId = cs.statId,
                          characterStatId = cs.characterStatId,
                          statName = cs.Stat.statName,
                          statValue = cs.statValue                           
                    };
                currChar.characterStatList.Add(scs);
            }
            foreach (var igs in iqgs)
            {
                var scs = new SCharacterSetting
                    {
                        characterID = igs.characterID,
                        modifierId = igs.GameSetting.modifierId,
                        modifierType = igs.GameSetting.Modifier.modifierType,
                        characterSettingId = igs.characterSettingId,
                        settingDescription = igs.GameSetting.settingDescription,
                        settingName = igs.GameSetting.settingName,
                        settingValue = igs.GameSetting.settingValue
                    };
                var gss = igs.GameSetting.Stat;
                scs.stat.statId = gss.statId;
                scs.stat.statName = gss.statName;
                currChar.characterSettingList.Add(scs);
            }
            foreach (var cp in iqcp)
            {
                var scp = new SCharacterPoint
                {
                    characterID = cp.characterID,
                    characterPointsId = cp.characterPointsId,
                    pointsId = cp.pointsId,
                    pointsName = cp.Point.pointsName,
                    pointsValue = cp.pointsValue                    
                };
                currChar.characterPointList.Add(scp);
            }

            foreach (var cp in iqcproj)
            {
                var scp = 
                    new SCharacterProjectile 
                    { 
                         characterId = cp.characterId,
                         characterProjectileId = cp.characterProjectileId,
                         particleId = cp.Projectile.particleId,
                         projectileHeight = cp.Projectile.projectileHeight,
                         projectileWidth= cp.Projectile.projectileWidth,
                         damageId =cp.Projectile.damageId,
                         damageDuration = cp.Projectile.Damage.damageDuration,
                         damageValue = cp.Projectile.Damage.damageValue,
                         projectileName = cp.Projectile.projectileName
                    };
                scp.force.forceName = cp.Projectile.forceName;
                scp.force.impulseX = (float)cp.Projectile.Force.impulseX;
                scp.force.impulseY = (float)cp.Projectile.Force.impulseY;
                scp.force.torque = (float)cp.Projectile.Force.torque;

                scp.projectileParticle.particleId = cp.Projectile.particleId;
                scp.projectileParticle.particleName = cp.Projectile.Particle.particleName;

                foreach (var psv in cp.Projectile.Particle.ParticleSettingValues)
                {
                    var spsv = new SParticleSettingValue();
                    spsv.particleId = psv.particleId;
                    spsv.particleSettingID = psv.particleSettingID;
                    spsv.particleSettingName = psv.ParticleSetting.particleSettingName;
                    spsv.particleSettingValue = psv.particleSettingValue1;
                    spsv.particleSettingValuesID = psv.particleSettingValueID;
                    scp.projectileParticle.particleSettingList.Add(spsv);
                }

                foreach (var pc in cp.Projectile.Particle.ParticleColours)
                {
                    var spc = new SParticleColour();
                    spc.colourHex = pc.colourHex;
                    spc.particleColourId = pc.particleColourId;
                    spc.particleId = pc.particleId;
                    scp.projectileParticle.particleColourList.Add(spc);
                }
                currChar.projectileList.Add(scp);
            }
            return currChar; 
        }

In the last 3 lines of code there is currChar.projectileList.Add(scp); , if I remove that line of code everything works fine. What I thought might be causing the problem is ciruclar references but I checked the classes and can't seem to find any. If needed I'll paste the code of the classes that have to do with projectileList

Update: Tried to debug the webservice itself and apparently there is a problem with the xml serialization, you can find the question here

+3  A: 

The error you're getting is a generic one and can be misleading. The problem in your case may be related to the fact that some types are not supported by Silverlight thus cannot be passed using WCF.

To get more detailed information about the error try using free tool called Fiddler. You can find detailed description of how to use it here: WCF Essentials - Fiddler

jarek
Thanks! the problem I was having was the result of a missing dll which I found out after following the instructions on the link you provided.
Ricardo
+1  A: 

Found the solution to my problem in my second question.

Drahcir