2009-05-02 87 views
9

我有一個Silverlight應用程序,它可以檢索可序列化類的列表。在這些類中還有其他可序列化的類,其中一些也在列表中。事情是一切工作正常,直到我填寫的序列化類的列表之一,導致Silverlight應用程序拋出異常「遠程服務器返回一個錯誤:NotFound」Silverlight Webservice「遠程服務器返回錯誤:NotFound」

這是填充類的代碼(唐'牛逼由大量的代碼,它只是與信息填充類)被嚇倒:

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; 
     } 

在過去的3行代碼有currChar.projectileList.Add(scp);,如果我刪除了這一行的代碼一切工作正常。我認爲可能導致問題的是ciruclar引用,但我檢查了類,似乎無法找到任何。如果需要的話,我會粘貼有projectileList

更新做類的代碼:試着調試Web服務本身,顯然有一個與XML序列化的問題,你可以找到這個問題here

回答

3

在我的second問題中找到解決我的問題的方法。

11

你得到的錯誤是一個通用錯誤,可能會引起誤解。 您的情況中的問題可能與某些類型不受Silverlight支持因此無法使用WCF傳遞有關。

要獲取有關錯誤的更多詳細信息,請嘗試使用名爲Fiddler的免費工具。 您可以在這裏找到如何使用它的詳細說明:WCF Essentials - Fiddler

+0

謝謝!我遇到的問題是根據您提供的鏈接上的說明找到的缺少dll的結果。 – 2010-10-20 15:22:23

13

下一次,你應該啓用WCF跟蹤:

把這個在你的web.config文件:

<system.diagnostics>  
    <sources> 
     <source name="System.ServiceModel" 
       switchValue="Information, ActivityTracing" 
       propagateActivity="true"> 
     <listeners> 
      <add name="traceListener" 
       type="System.Diagnostics.XmlWriterTraceListener" 
       initializeData= "c:\temp\WEBTraces.log" /> 
     </listeners> 
     </source> 
    </sources> 
    </system.diagnostics> 

更多的這樣的位置:http://msdn.microsoft.com/en-us/library/ms733025.aspx

+2

我發現Windows中的事件查看器記錄了這些錯誤,並且它產生了一個非常緊湊和可讀的錯誤消息,幫助我調試NotFound錯誤。 – angularsen 2011-04-07 19:17:06

相關問題