2009-10-24 7 views
0

J'ai une application web ASPX dont une page devrait charger une application Silverlight. Le problème que je rencontre est que l'application Silverlight n'apparaît sur aucune page ASPX mais sur les pages HTML. Ceci utilise le serveur de développement ASP.Net de VS. Lorsque j'ai ajouté l'application SL, VS a créé deux pages de test. Comme mentionné la page HTML fonctionne, mais pas la page de test ASPX. J'ai créé une copie de la page HTML en tant que page ASPX et cela ne fonctionne pas. L'exécution à travers Fiddler et Silverlight Spy montre qu'aucune tentative n'est faite pour télécharger l'application Silverlight (pas de ligne dans Fiddler) ou même démarrer le plugin Silverlight (clic-droit n'importe où sur la page n'affiche pas le menu contextuel Silverlight). Aucune page de chargement ou des erreurs JavaScript sont signalés par IE ou Firefox après le chargement des pages ASPXSilverlight dans la page ASPX ne se charge pas, mais le fait en HTML

J'ai essayé la méthode <object> ainsi que la <asp:silverlight>. Personne ne me donne de joie.

Voici le code de la page HTML généré par VS qui fonctionne:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head> 
    <title>Web.DataAnalytics.Dashboard</title> 

    <style type="text/css"> 
    html, body { 
     height: 100%; 
     overflow: auto; 
    } 
    body { 
     padding: 0; 
     margin: 0; 
    } 
    #silverlightControlHost { 
     height: 100%; 
    } 
    </style> 
    <script type="text/javascript" src="./Silverlight.js"></script> 
    <script type="text/javascript"> 
     function onSilverlightError(sender, args) { 

      var appSource = ""; 
      if (sender != null && sender != 0) { 
       appSource = sender.getHost().Source; 
      } 
      var errorType = args.ErrorType; 
      var iErrorCode = args.ErrorCode; 

      var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n" ; 

      errMsg += "Code: "+ iErrorCode + " \n"; 
      errMsg += "Category: " + errorType + "  \n"; 
      errMsg += "Message: " + args.ErrorMessage + "  \n"; 

      if (errorType == "ParserError") 
      { 
       errMsg += "File: " + args.xamlFile + "  \n"; 
       errMsg += "Line: " + args.lineNumber + "  \n"; 
       errMsg += "Position: " + args.charPosition + "  \n"; 
      } 
      else if (errorType == "RuntimeError") 
      {   
       if (args.lineNumber != 0) 
       { 
        errMsg += "Line: " + args.lineNumber + "  \n"; 
        errMsg += "Position: " + args.charPosition + "  \n"; 
       } 
       errMsg += "MethodName: " + args.methodName + "  \n"; 
      } 

      throw new Error(errMsg); 
     } 
    </script> 
</head> 

<body> 
    <!-- Runtime errors from Silverlight will be displayed here. 
    This will contain debugging information and should be removed or hidden when debugging is completed --> 
    <div id='errorLocation' style="font-size: small;color: Gray;"></div> 

    <div id="silverlightControlHost"> 
     <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> 
      <param name="source" value="./ClientBin/Web.DataAnalytics.Dashboard.xap"/> 
      <param name="onerror" value="onSilverlightError" /> 
      <param name="background" value="white" /> 
      <param name="minRuntimeVersion" value="2.0.31005.0" /> 
      <param name="autoUpgrade" value="true" /> 
      <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"> 
       <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> 
      </a> 
     </object> 
     <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe> 
    </div> 
</body> 
</html> 

Voici le code du test ASPX généré par VS qui ne fonctionne pas:

<%@ Page Language="c#" AutoEventWireup="true" %> 

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" 
    TagPrefix="asp" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;"> 
<head runat="server"> 
    <title>Web.DataAnalytics.Dashboard</title> 
</head> 
<body style="height:100%;margin:0;"> 
    <form id="form1" runat="server" style="height:100%;"> 
     <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
     <div style="height:100%;"> 
      <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/Web.DataAnalytics.Dashboard.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" /> 
     </div> 
    </form> 
</body> 
</html> 

ici est la page ASPX que j'ai créée à partir de la page HTML de travail, qui ne fonctionne pas non plus:

<%@ Page Language="c#" AutoEventWireup="true" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title>Web.DataAnalytics.Dashboard</title> 

    <style type="text/css"> 
    html, body { 
     height: 100%; 
     overflow: auto; 
    } 
    body { 
     padding: 0; 
     margin: 0; 
    } 
    #silverlightControlHost { 
     height: 100%; 
    } 
    </style> 
    <script type="text/javascript" src="./Silverlight.js"></script> 
    <script type="text/javascript"> 
     function onSilverlightError(sender, args) { 

      var appSource = ""; 
      if (sender != null && sender != 0) { 
       appSource = sender.getHost().Source; 
      } 
      var errorType = args.ErrorType; 
      var iErrorCode = args.ErrorCode; 

      var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n" ; 

      errMsg += "Code: "+ iErrorCode + " \n"; 
      errMsg += "Category: " + errorType + "  \n"; 
      errMsg += "Message: " + args.ErrorMessage + "  \n"; 

      if (errorType == "ParserError") 
      { 
       errMsg += "File: " + args.xamlFile + "  \n"; 
       errMsg += "Line: " + args.lineNumber + "  \n"; 
       errMsg += "Position: " + args.charPosition + "  \n"; 
      } 
      else if (errorType == "RuntimeError") 
      {   
       if (args.lineNumber != 0) 
       { 
        errMsg += "Line: " + args.lineNumber + "  \n"; 
        errMsg += "Position: " + args.charPosition + "  \n"; 
       } 
       errMsg += "MethodName: " + args.methodName + "  \n"; 
      } 

      throw new Error(errMsg); 
     } 
    </script> 
</head> 

<body> 
    <!-- Runtime errors from Silverlight will be displayed here. 
    This will contain debugging information and should be removed or hidden when debugging is completed --> 
    <div id='errorLocation' style="font-size: small;color: Gray;"></div> 

    <div id="silverlightControlHost"> 
     <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> 
      <param name="source" value="./ClientBin/Web.DataAnalytics.Dashboard.xap"/> 
      <param name="onerror" value="onSilverlightError" /> 
      <param name="background" value="white" /> 
      <param name="minRuntimeVersion" value="2.0.31005.0" /> 
      <param name="autoUpgrade" value="true" /> 
      <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"> 
       <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> 
      </a> 
     </object> 
     <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe> 
    </div> 
</body> 
</html> 

Toute aide serait grandement appréciée

+1

Essayez d'écrire votre code. – thomasmartinsen

Répondre

0

Trouvé la question:

Nous avons un thème qui est appliqué aux pages ASPX. Dans le CSS, l'entrée suivante existe:

OBJECT { 

DISPLAY: none 

} 

Après avoir supprimé ce style offensant, l'application Silverlight est apparue.

Je l'ai trouvé en copiant le code HTML ASPX dans une nouvelle page HTML et j'ai constaté que cela ne fonctionnait pas non plus! La seule différence que je pourrais trouver est le CSS inclus dans l'en-tête. Lorsque cette entrée a été supprimée, l'application Silverlight fonctionne. En utilisant IE8 Developer Tools, j'ai commencé à examiner de près le CSS appliqué et trouvé la règle ci-dessus appliquée à mon entrée Object.

Merci quand même les gars. Shout out à l'homme à Silverlight.Net Forums; ils étaient vraiment désireux et utile pour moi quand j'ai posté la même question/problème à eux

Questions connexes