【问题标题】:Silverlight works in IE, blank page in other browsersSilverlight 在 IE 中工作,在其他浏览器中显示空白页面
【发布时间】:2013-01-27 05:11:51
【问题描述】:

我是 SilverLight 的新手,我正在尝试复制 Matthew MacDonald 的“Pro Silverlight 5 in C#”一书中的一个简单示例。

我正在使用 VS2012 创建 Silverlight 5 应用程序。

当我运行 SilverlightApplication1TestPage.html - 它在 IE10 中有效,但在 FF 和 Chrome 中我得到一个空白页。 SilverLight 插件在这些浏览器中加载,但不显示任何内容。

请给我任何关于为什么会发生这种情况的建议。

MainPage.xaml代码如下。

<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White">
    <StackPanel>
        <TextBlock x:Name="lblMessage" Text="Hello World!" Margin="5"></TextBlock>
        <Button x:Name="cmdClickMe" Content="Click Me!" Margin="5" Click="cmdClickMe_Click" />
    </StackPanel>
</Grid>

MainPage.xaml.cs 包含以下处理程序。

 private void cmdClickMe_Click(object sender, RoutedEventArgs e)
    {
        lblMessage.Text = "Goodbye, cruel world.";
    }

html 页面如下所示(正文部分)。

<body>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <param name="source" value="SilverlightApplication1.xap"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="5.0.61118.0" />
      <param name="autoUpgrade" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none">
          <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
      </a>
    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</form>

【问题讨论】:

  • HTML 是什么样的?
  • 我在上面贴了html 。
  • 您可以运行该链接,看看银灯在您的计算机上的 Firefox 中是否正常工作:bubblemark.com/silverlight2.html
  • 气泡动画在 FF 和 Chrome 中运行良好。
  • 我在另一台计算机上测试了这个项目,它可以在 IE10 和 Chrome 中运行。所以也许我的机器上的设置有些问题。然而,上面的气泡测试在我机器上的浏览器中运行良好。

标签: visual-studio-2010 xaml silverlight-4.0 cross-browser silverlight-5.0


【解决方案1】:

问题是Silverlight项目目录位于“C:\Users\\Documents\Visual Studio 2012\Projects”下,其中不是用英文写的。

我将 .html 和 .xap 文件移动到 C:\ 并且投影在所有浏览器中都可以正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-18
    • 2016-12-30
    相关资源
    最近更新 更多