views:

15

answers:

1

Im attempting to use Silverlight and MVC together. After creating a simple Silverlight application I attempted to view it using the MVC host application (using the provided aspx and html pages). The issue is that when I view the page all I see is the Loading image (with a 100% value) and that is all. It never displays my app!

Here is the html for the aspx page:

<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="ClientBin/MVCSilverlight.xap"/>
          <param name="onError" value="onSilverlightError" />
          <param name="background" value="white" />
          <param name="minRuntimeVersion" value="3.0.40818.0" />
          <param name="autoUpgrade" value="true" />
          <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40818.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>

And here is the xaml for the application:

<UserControl x:Class="MVCSilverlight.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"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
    mc:Ignorable="d"
    d:DesignHeight="500" d:DesignWidth="500">

    <Canvas x:Name="LayoutRoot" Background="Crimson">        
        <TextBlock Text="Hello World" ></TextBlock>
    </Canvas>
</UserControl>

Everything else in the application is standard code (code that was generated when I created the project). Has someone seen this issue before? Is there something that I'm missing? I'm very new to both technologies to any info will be very helpful.

+1  A: 

When you run the app check that VS has attached to the browser process for Silverlight debugging (not Script).

Also check your App.xaml.cs contains:-

    private void Application_Startup(object sender, StartupEventArgs e)
    {
        this.RootVisual = new MainPage();
    } 

The loading splash screen will remain in place whilst the RootVisual remains unset. So either the code just doesn't set it or an error is occuring (and for some reason your not being alerted of the error) so that code never reaches the assignment of RootVisual.

Also get yourself a the free HTTP debugging tool called Fiddler so you can trace all the actual HTTP conversations, perhaps the xap isn't being downloaded at all for some reason. In fact that would be my guess, the MVC routing might be doing something undesirable with "ClientBin/MVCSilverlight.xap".

AnthonyWJones
You were right, it was not downloading. The issue was with some styles that I created that the application was not finding (I was initially testing in FireFox and it wasnt throwing the error, had to go to IE). Actually, the application is not finding anything that I place in the Application.Resources (uri mappings and styles).
The Sheek Geek