我的 Silverlight 应用程序不显示更改

发布于 2024-09-28 19:29:23 字数 3034 浏览 0 评论 0原文

这是我第一次使用 SL(但不是 WPF)。我正在学习 PRISM,观看 MTaulty 的精彩视频:http://channel9.msdn.com/blogs/mtaulty/prism--silverlight-part-1-take-sketched-code-towards-unity

到目前为止一切顺利,我同意上一个视频,我正在做他在我的VS中做的同样的事情。我正在使用 SL4 和mvc2 网络& sl4 棱镜。

我发现了一个问题,但我不知道发生了什么。

我的 SL 应用程序本身没有显示任何更改。我有一个基本的外壳:

<Grid x:Name="LayoutRoot" Background="Azure">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="2*" />
    </Grid.ColumnDefinitions>
    <ctls:GridSplitter Grid.RowSpan="2" HorizontalAlignment="Right"
                       VerticalAlignment="Stretch" Width="2"
                       Background="Black" />
    <ctls:GridSplitter Grid.Column="1"
                       HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
                       Height="2" Background="Black" />

    <Border Background="SkyBlue" CornerRadius="3"
            Margin="5" Grid.RowSpan="2">
        <ContentControl rgn:RegionManager.RegionName="FolderSelectionRegion"
                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                        HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
    </Border>
    <Border
        Background="SkyBlue"
        CornerRadius="3"
        Margin="5"
        Grid.Column="1">
        <ContentControl
            rgn:RegionManager.RegionName="MailSelectionRegion"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            HorizontalContentAlignment="Stretch"
            VerticalContentAlignment="Stretch" />
    </Border>
</Grid>

问题是,我在第一个 RegionManager 中注册了一个视图,完美,我注册了第二个视图,但它没有显示...好吧,某个地方有一些错误...但是没有。

我意识到第二个 RegionManager 的边框没有显示,好吧。我评论了注册视图的行(视图正在工作)并且视图仍然显示。我评论了引导程序,将其从 Application_Startup 中删除,视图中仍然没有显示任何内容(不可能,我的应用程序不可能知道如何执行 Shell,全部都被注释掉了)。

简而言之,我确信如果我删除 3 个文件,应用程序仍然可以工作...我清理了解决方案,从 ClientBin 中删除了 .xap 文件...什么都没有,应用程序仍然显示视图等等。换句话说,应用程序没有反映代码上的更改。

这是怎么回事?

谢谢。

编辑:大约一年后...

所以,从那时起我就没有接触过Silverlight,但今天我想制作一个非常简单的应用程序(只是一个路径和文本框)并且...耶我的应用程序开始不显示更改。

我无法重现该错误,我不知道是什么触发了此错误,但我知道这是 ASP.NET MVC 的问题。

我这里说的项目,和我今天做的项目,都是使用ASP.NET MVC来启动SL项目。

我将EmailClient项目(只是我们感兴趣的部分)上传到我的主机:www.foxandxss.net/stuff/EmailClient.rar

很容易看出问题。首先,您可以看到在 Shell.xaml 中,LayoutRoot 的颜色是 Azure,如果您运行该应用程序,它将是绿色(当我今天打开这个应用程序时,我将其更改为绿色并工作,但没有更多更改)。如果您将颜色更改为另一种颜色,它不会改变。如果您转到 App.xaml.cs 并注释创建和运行引导程序的行(因此应用程序将不会运行),应用程序仍将打开。就像运行的应用程序是一些缓存,你所做的每一个更改,你都不会看到它。

我尝试从 MVC 项目中删除 xap,但没有任何结果。

问题是,如果您右键单击 SL 项目并单击“在浏览器中查看”,您将看到更改(Azure BG,或者如果您注释了 boostrapper,则什么也看不到),但如果您从 MVC 项目运行它,则什么也看不到。

It's my first time with SL (but not WPF). Im learning PRISM watching the great videos of MTaulty: http://channel9.msdn.com/blogs/mtaulty/prism--silverlight-part-1-taking-sketched-code-towards-unity

So far so good, I'm with the last video and I'm doing the same things He does in my VS. I'm using SL4 & mvc2 web & prism for sl4.

I Found a problem and I don't know what is going on.

My SL application itself doesnt show any changes. I have a basic shell:

<Grid x:Name="LayoutRoot" Background="Azure">
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="2*" />
    </Grid.ColumnDefinitions>
    <ctls:GridSplitter Grid.RowSpan="2" HorizontalAlignment="Right"
                       VerticalAlignment="Stretch" Width="2"
                       Background="Black" />
    <ctls:GridSplitter Grid.Column="1"
                       HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
                       Height="2" Background="Black" />

    <Border Background="SkyBlue" CornerRadius="3"
            Margin="5" Grid.RowSpan="2">
        <ContentControl rgn:RegionManager.RegionName="FolderSelectionRegion"
                        HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                        HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
    </Border>
    <Border
        Background="SkyBlue"
        CornerRadius="3"
        Margin="5"
        Grid.Column="1">
        <ContentControl
            rgn:RegionManager.RegionName="MailSelectionRegion"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            HorizontalContentAlignment="Stretch"
            VerticalContentAlignment="Stretch" />
    </Border>
</Grid>

The thing is, I registered a View in the first regionManager, perfect, I registered a second view but it doesnt show... Ok, some bug in someplace... but no.

I realized that the border for the second regionManager is not showing up, ok. I commented the line that register the view (the view is working) and the view is still showing up. I commented the bootstrapper, deleting it from Application_Startup, nothing the view is still showing up (not possible, there is no way that my app knows how to execute the Shell, is all commented out).

In short, I'm sure if I Delete 3 files, the app is still working... I cleaned the solution, deleted the .xap files from the ClientBin... Nothing, the app is still showing up the view and so on. On other words, the app is not reflecting changes on the code.

What's going on?

Thank you.

EDIT: Near one year later...

So, I didn't touch Silverlight since this, but today I wanted to make a very simple app (just a path and textbox) and... Yay my app started to dont show the changes.

I can't reproduce the bug, I don't know what trigger this, but I know that is a problem with ASP.NET MVC.

The project Im talking here, and the project I made today, both were using ASP.NET MVC to launch the SL project.

I uploaded the EmailClient project (just the part we are interested in) to my host: www.foxandxss.net/stuff/EmailClient.rar

Is easy to see the problem. For start, you can see that in Shell.xaml, the LayoutRoot's color is Azure and if you run the application, it will be Green (When I opened today this app, I changed it to Green and worked, but no more changes). If you change the color to another one, it didn't change. If you go to App.xaml.cs and comment the lines that creates and run the bootstrapper (so the app will not run), the app will still opening. Is like the app running is some cache and everychange you make, you wont see it.

I tried deleting the xap from the MVC project, and nothing.

The thing is that if you right click on the SL project and click on "View in browser" you will see the changes (Azure BG or nothing if you commented the boostrapper) but if you run it from the MVC project, nothing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缺⑴份安定 2024-10-05 19:29:23

过去,我在 XAP 文件缓存方面遇到过问题。如果这是问题,我会在 xap 文件路径旁边注入一个虚拟参数(在本例中为时间戳):

<div id="silverlightControlHost">
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <param name="source" value="ClientBin/EmailClient.xap?20110712160700"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50826.0" />
      <param name="autoUpgrade" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.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>

如果您在每次构建时刷新该参数,这将使缓存失效并加载最新的 xap 文件。

In the past, I had issues with XAP file caching. If it's the issue, I would inject a dummy parameter next to the xap file path (in this case a timestamp) :

<div id="silverlightControlHost">
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <param name="source" value="ClientBin/EmailClient.xap?20110712160700"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50826.0" />
      <param name="autoUpgrade" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.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>

If you refresh that parameter on each build, this should invalidate the cache and load the latest xap file.

白衬杉格子梦 2024-10-05 19:29:23

Samuel 的想法是正确的,但是您可以通过检查服务器上的上次写入时间来让 Silverlight 自动忽略以前的时间戳

<div id="silverlightControlHost">
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <%
          const string orgSourceValue = @"ClientBin/SilverlightApp.xap";
          string param;
          if (System.Diagnostics.Debugger.IsAttached)
              param = "<param name=\"source\" value=\"" + orgSourceValue + "\" />";
          else
          {
              string xappath = HttpContext.Current.Server.MapPath(@"") + @"\" + orgSourceValue;
              DateTime xapCreationDate = System.IO.File.GetLastWriteTime(xappath);
              param = "<param name=\"source\" value=\"" + orgSourceValue + "?ignore=" + xapCreationDate.ToString("yyyy-MM-dd_HH-mm-ss") + "\" />";
          }
          Response.Write(param);
      %>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50401.0" />
      <param name="autoUpgrade" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.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>

Samuel has the right idea, however you can get Silverlight to automatically ignore previous timestamps by checking the last write time on the server

<div id="silverlightControlHost">
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <%
          const string orgSourceValue = @"ClientBin/SilverlightApp.xap";
          string param;
          if (System.Diagnostics.Debugger.IsAttached)
              param = "<param name=\"source\" value=\"" + orgSourceValue + "\" />";
          else
          {
              string xappath = HttpContext.Current.Server.MapPath(@"") + @"\" + orgSourceValue;
              DateTime xapCreationDate = System.IO.File.GetLastWriteTime(xappath);
              param = "<param name=\"source\" value=\"" + orgSourceValue + "?ignore=" + xapCreationDate.ToString("yyyy-MM-dd_HH-mm-ss") + "\" />";
          }
          Response.Write(param);
      %>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50401.0" />
      <param name="autoUpgrade" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文