silverlight   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Silverlight Webservice“远程服务器返回错误:NotFound”大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

有一个Silverlight应用程序,可以追溯可序列化的类列表.在这些类中有其他的可序列化类,其中一些也在列表中.事情是一切正常,直到我填写可序列化的列表之一,导致silverlight应用程序抛出异常“远程服务器返回错误:NotFound” 这是填充类的代码(不要被大量的代码吓倒,只是用信息填充类): private SCharacter getSCharacter(Character use
@H_674_13@
我有一个Silverlight应用程序,可以追溯可序列化的类列表.在这些类中有其他的可序列化类,其中一些也在列表中.事情是一切正常,直到我填写可序列化的列表之一,导致silverlight应用程序抛出异常“远程服务器返回错误: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有关的类的代码

更新:试图调试webservice本身,显然xml序列化有一个问题,你可以找到问题here

解决方法

下一次,您应该启用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

大佬总结

以上是大佬教程为你收集整理的Silverlight Webservice“远程服务器返回错误:NotFound”全部内容,希望文章能够帮你解决Silverlight Webservice“远程服务器返回错误:NotFound”所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。