Silverlight 加载我的业务应用程序会花费太长时间吗?
我认为 Silverlight 4.0 将是构建我们的业务应用程序的不错选择。
然而,我担心的一个部分是加载。如果我理解正确的话,Silverlight 将所有页面编译成一个二进制文件,该二进制文件在加载时加载到客户端上。现在只要几页就可以了,但是如果我达到数百页,这个加载时间会变得非常长吗?当我查看 Infragistics 和 Telerik 上的示例时,他们需要 10-15 秒才能加载这几个示例。我觉得这是不可接受的。
有办法解决这个问题吗?
I'm thinking that Silverlight 4.0 would be a good choice to build our business application.
However, the one part I'm afraid of is the loading. If I understand it correctly, Silverlight compiles ALL the pages into one binary, which is loaded on the client at load time. It's fine now with just a few pages, but if I reach hundreds of pages, will this load time get extremely long? When I look at examples on Infragistics and Telerik, they take a good 10-15 seconds to load just those few examples. I find this unacceptable.
Are there ways around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这确实是一个问题。但是二进制文件(xap 文件,实际上只是 dll 的 zip)是通过标准 HTTP 提供的,因此它们当然可以被缓存(可以通过您的 Web 服务器进行配置)。因此第一次下载可能需要 15 秒,但所有后续加载应该基本上没有下载时间(除非您发布更新)。
此外,Telerik 示例引用了所有 dll,您可以删除自己项目中不需要的 dll,以减少总体大小。
有多种产品和技术可以为您的 xap 添加额外的压缩(因为它们实际上只是 zip 文件)
http://www.google.com/search?q=silverlight+xap+compactor.....
我认为 Telerik 也提供了一种这样的工具。
最后,在 4.0 中,您可以将某些系统 dll 设置为按需加载,而不是预先加载,这可以缩短下载时间(但我个人没有使用过这个) - 它位于项目属性中。
Yes, it is indeed a problem. But the binaries (xap files, which are really just a zip of the dlls) are served up via standard HTTP, so they can certainly be cached (as configurable via your web server). So the first download might take 15 seconds, but all subsequent loads should have basically no download time (unless you release an update).
Also, the Telerik examples have all of their dlls referenced, and you can eliminate the ones you don't need in your own project to reduce overall size.
There are several products and techniques for adding additional compression to your xaps (since they are just zip files really)
http://www.google.com/search?q=silverlight+xap+compactor.....
I think Telerik offers one such tool too.
Lastly, in 4.0, you can set certain System dlls to load on demand instead of up front which can improve download time (but I haven't personally used this) - -it's in the project properties.
还可以使用多个 xap 文件,因此您可以将应用程序拆分为单独的 xap 文件。
我从来没有尝试过这个,但如果你用谷歌搜索,你会发现很多文章。例如
http://dotplusnet.blogspot。 com/2010/09/how-to-load-multiple-xap-files-in.html
It's also possible to use multiple xap files, so you could split your application up into seperate xap files.
I've never tried this but if you google then you'll find lots of articles. E.g.
http://dotplusnet.blogspot.com/2010/09/how-to-load-multiple-xap-files-in.html
首先 - DLL 和您自己的任何导入资源(大图像等)可能会使 xap 的大小膨胀。因此,如果您有一个相对同质的网站,基于相同的外观/模板,添加新页面不会增加整体大小太多,因为所需的组件已经在 xap 中,并且添加的内容主要由文本组成。
当然,如果新页面具有需要包含额外 dll 的功能/使用控件或组件,这会降低页面的重量,但是当您谈论一个应用程序时,该应用程序可能会增长到数百个页面,我认为它们会有些连贯。
您还可以让 Silverlight 应用程序在需要时动态加载内容。如果您可以将内容和/或内容描述符/资产与代码分开,您应该看看是否可以将其存储在数据库或其他存储库中,并仅在需要时获取它。
还可以在运行时动态加载其他 xap,从而允许您最初进行轻量级 xap 加载,然后按需引入其他 xap,从而根据用户在“会话”期间的需求分散加载时间。
Firstly - what's likely to bloat the size of the xap are dlls and any imported assets of your own (large images etc). So if you have a relatively homogeneous site, based on the same look / templates across, adding new pages won't increase the overall size much, since the needed components are already in the xap and the additions will mostly consist of text.
Of course, if the new pages have functionality / use controls or components that require additional dlls to be included, that will weigh it down, but when you're talking about one application that could grow to hundreds of pages, I assume they will be somewhat coherent.
You can also have the Silverlight app dynamically load content when needed. If you can separate content and/or content descriptors / assets from the code, you should see whether it's possible to store that in a database or other repository and fetch it only when needed.
It is also possible to load other xaps dynamically at runtime, allowing you to have a lightweight xap load initially, and then bring in the others on demand and thus spread the load time out based on what is required by the user during the "session".