C# Silverlight、Wpf Web App (xbap) 还是 Click Once?利弊
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/251718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Silverlight, Wpf Web App (xbap) or Click Once? Pros and Cons
提问by Mark
We are starting a new project and I'm trying to decide which of the Wpf-esque develop/deploy strategies we should go with. In our case we are looking at quite a complex business app that will be used by 100s (not 1000s) of people, So I'm leaning towards a click-once app. My boss likes the idea of a Silverlight app as it means easier deployment. So which way should we jump?
我们正在开始一个新项目,我正在尝试决定我们应该采用哪种 Wpf 式的开发/部署策略。在我们的例子中,我们正在研究一个相当复杂的商业应用程序,它将被 100 多位(而不是 1000 多位)人使用,所以我倾向于点击一次应用程序。我的老板喜欢 Silverlight 应用程序的想法,因为这意味着更容易部署。那么我们应该往哪个方向跳呢?
The answer is, of course, "it depends". So what are the pros and cons of each?
答案当然是“视情况而定”。那么每种方法的优缺点是什么?
I'll start the ball rolling (EditAdded in some answers from artur carvalho):
我将开始滚动(在artur carvalho 的一些答案中添加了编辑):
Silverlight
银光
- Pros
- 优点
Cross browser
Doesn't require full framework.
Better control of users. If your users login, you dont have to worry with activation keys or similar stuff.
It works on Windows and Mac.
You can update all your users apps easily.
跨浏览器
不需要完整的框架。
更好地控制用户。如果您的用户登录,您不必担心激活密钥或类似的东西。
它适用于 Windows 和 Mac。
您可以轻松更新所有用户应用程序。
- Cons
- 缺点
Can't interact with client's file system etc
Has less functionality compared with full Wpf (anyone got a good resource that documents differences?)
Single window
Single version
无法与客户端的文件系统等交互 与
完整的 Wpf 相比功能较少(任何人都有记录差异的好资源?)
单窗口
单版本
Wpf Web App (xbap)
Wpf 网络应用程序 (xbap)
- Pros
- 优点
Full Wpf.
全Wpf。
- Cons
- 缺点
Single browser
Requires full framework
Can't interact with client's file system etc
Single window
Single version
单浏览器
需要完整的框架
不能与客户端的文件系统等交互
单窗口
单版本
Wpf Click once
Wpf 点击一次
- Pros
- 优点
Full Wpf
Can work offline
Multiple windows
Multiple versions (con?)
Better access to low level parts of the computer
No downtime for maintenance
完整的 Wpf
可以离线工作
多个窗口
多个版本 (con?)
更好地访问计算机的低级部分
无需停机维护
- Cons
- 缺点
Single browser
Requires full framework
Slightly(?) harder to install.
单一浏览器
需要完整框架安装
稍难(?)。
回答by Marc Gravell
First, I would evaluate whether a web client (ideally MVC+jQuery) can't do the job...
首先,我会评估 Web 客户端(理想情况下是 MVC + jQuery)是否无法完成这项工作......
Assuming a full client is warranted:
假设一个完整的客户端是有保证的:
If it is a business app that demands a client, I would tend to go with the full framework and ClickOnce; the main difference here (re deployment) is that the client must have the framework installed - but past that, ClickOnce deployment is very pain free. Actually, building a ClickOnce manifest is much easierthan Silverlight etc, since the IDE will do almost all of it for you; you just have to host the files somewhere (could be a web URL; could be a network UNC).
如果它是一个需要客户端的商业应用程序,我会倾向于使用完整的框架和 ClickOnce;这里的主要区别(重新部署)是客户端必须安装框架 - 但除此之外,ClickOnce 部署非常轻松。实际上,构建 ClickOnce 清单比 Silverlight 等要容易得多,因为 IDE 几乎会为您完成所有工作;您只需要将文件托管在某处(可能是 Web URL;可能是网络 UNC)。
This gives you muchmore control (and power) at the client, as well as a far greater range of existing resources to use (for example, if you need, you can use some legacy winform code on the WPF surface). The "requires full framework" is also one of the largest benefits: "has full framework".
这为您提供了更多的客户端控制(和权力),以及更大范围的现有资源可供使用(例如,如果您需要,您可以在 WPF 表面上使用一些遗留的 winform 代码)。“需要完整的框架”也是最大的好处之一:“拥有完整的框架”。
You should also perhaps consider the 3.5 "client profile" setup; not sure how wide-spread this is in reality... but worth knowing about.
您或许还应该考虑 3.5“客户端配置文件”设置;不确定这在现实中有多广泛……但值得了解。
回答by Artur Carvalho
You can add to the pros and cons of the usual stuff of the online vs offline debate. Some items:
您可以添加在线与离线辩论的常用内容的利弊。一些项目:
Pros
优点
wpf(offline):
wpf(离线):
- better access to low level parts of the computer.
- cpu usage is local, so you rarely have cpu load issues.
- not dependent of the net.
- no downtime for maintenance.
- 更好地访问计算机的低级部分。
- cpu 使用是本地的,因此您很少遇到 cpu 负载问题。
- 不依赖网络。
- 无需停机维护。
silverlight(online):
银光(在线):
- Better control of users. If your users login, you dont have to worry with activation keys or similar stuff.
- It works on Windows and Mac.
- You can update all your users apps easily.
- 更好地控制用户。如果您的用户登录,您不必担心激活密钥或类似的东西。
- 它适用于 Windows 和 Mac。
- 您可以轻松更新所有用户应用程序。
I simplified it a bit, there are gray areas in the list. I only tinkered with XBAP, so that one I'll leave out. The Cons are not hard to figure out after looking to the pros.
我简化了一点,列表中有灰色区域。我只对 XBAP 进行了修补,所以我会遗漏一个。在查看了优点之后,不难发现缺点。
HTH
HTH
回答by Philipp Schmid
I would consider WPF ClickOnce with sync framework support (www.msdn.com/sync). This would allow you to support limited functionality when the user is not connected to the corporate network (which will eliminate any browser-based deployment scenarios, such as Silverlight and XBAP).
我会考虑 WPF ClickOnce 与同步框架支持 ( www.msdn.com/sync)。这将允许您在用户未连接到公司网络时支持有限的功能(这将消除任何基于浏览器的部署方案,例如 Silverlight 和 XBAP)。
回答by Abdu
You didn't say if this is a company only application or a public facing one. That alone will decide it for you.
您没有说这是仅限公司的应用程序还是面向公众的应用程序。只有这一点才能为您决定。
If company only, I would go with full WPF click once. This will give you everything. Full framework should not be an issue. It's a one time install running in the background so it's not something that your decision should depend on. Cons: it runs in Windows only but if your company is Windows only, this should not be an issue.
如果只是公司,我会使用完整的 WPF 单击一次。这会给你一切。完整的框架应该不是问题。这是在后台运行的一次性安装,因此您的决定不应该依赖于此。缺点:它仅在 Windows 中运行,但如果您的公司仅使用 Windows,这应该不是问题。
However WPF apps could be resource hungry so you need to know if all your client machines are capable of running WPF apps smoothly.
然而,WPF 应用程序可能会占用大量资源,因此您需要知道您的所有客户端计算机是否都能够顺利运行 WPF 应用程序。
If it's an Internet app, go for Silverlight: it runs under different operating systems.
如果它是一个 Internet 应用程序,请选择 Silverlight:它在不同的操作系统下运行。
回答by DaniCE
If you don't need all WPF I would try do it in Silvelight first Then you can switch to WPF more easily if you need it later.
如果您不需要所有 WPF,我会先尝试在 Silvelight 中进行然后如果以后需要,您可以更轻松地切换到 WPF。
Here I think it applies the “less is more” principle: it's true that with WPF you have much more options and can access to the user computer, but that can finally be more a problem than a help as the times go. Think for example in how many changes you can need to change from Windows XP to Vista in an application that uses a lot of the “user computer” resources!
在这里,我认为它应用了“少即是多”的原则:确实,使用 WPF,您有更多的选择,并且可以访问用户计算机,但随着时间的推移,这最终会成为问题而不是帮助。例如,在使用大量“用户计算机”资源的应用程序中,从 Windows XP 更改为 Vista 需要多少更改!
回答by IgorK
Mark, what do you mean when saying 'single browser' for XBAP? XBAP does work with Firefox for example. It indeed requires .NET Framework and it is unlikely that we will have WPF in Mono anywhere soon (if ever) so you are stuck with Windows, that's right.
马克,你说 XBAP 的“单一浏览器”是什么意思?例如,XBAP 确实适用于 Firefox。它确实需要 .NET Framework,而且我们不太可能很快(如果有的话)在 Mono 中使用 WPF,因此您只能使用 Windows,这是正确的。
回答by IgorK
The pros
优点
- The Silverlight plug-in means developers can target a single, consistent runtime for browser-based applications, rather than dealing with the complexity of multiple browsers in different versions. You also get video and multimedia effects that are hard or impossible with pure HTML and JavaScript, though Adobe Systems' Flash has the same advantages.
- Execute .NET code without deploying the .NET runtime. The Silverlight plug-in does include a cut-down .NET runtime, but instead of dealing with a large download and the complexities of the Windows installer, the user has a small download of about 4MB, all handled within the browser. In my experience so far, installation is smooth and easy.
- Performance is promising. Silverlight comes out well in this prime number calculator, thanks no doubt to JIT compilation to native code, though it may not compare so well for rendering graphics.
- Support for Moonlight means there will be an official open source implementation of Silverlight, mitigating the proprietary aspect.
- Silverlight interprets XAML directly, whereas Adobe's XML GUI language, MXML, gets converted to SWF at compiling time. In fact, XAML pages are included as resources in the compiled .XAP binary used for deploying Silverlight applications. A .XAP file is just a ZIP with a different extension. This also means that search engines can potentially index text within a Silverlight application, just as they can with Flash.
- Third-party component vendors are already well on with Silverlight add-ons. For example, Infragistics, ComponentOne and DevExpress.
- Take your .NET code cross-platform. With Macs popping up everywhere, the ability to migrate Visual Basic or C# code to a cross-platform, browser-based Silverlight client will be increasingly useful. Clearly this only applies to existing .NET developers - I guess this is the main market for Silverlight, but it is a large one. The same applies to the next point:
- Uses Visual Studio. Microsoft's IDE is a mature and well-liked development environment, and since it is also the tool for ASP.NET you can use it for server-side code, as well as for the Silverlight client. For those who don't get on with Visual Studio, the Silverlight SDK also supports command-line compilation.
- Choose your language. Support for multiple languages has been part of .NET since its beginning, and having the .NET runtime in Silverlight 2.0 means you can code your client-side logic in C#, Visual Basic, or thanks to the Dynamic Language Runtime (DLR) Iron Ruby or Iron Python.
- Isolated storage gives Silverlight applications local file access, but only in a protected location specific to the application, providing a relatively secure way to get this benefit.
- Silverlight 插件意味着开发人员可以针对基于浏览器的应用程序的单一、一致的运行时,而不是处理不同版本的多个浏览器的复杂性。您还可以获得纯 HTML 和 JavaScript 很难或不可能实现的视频和多媒体效果,尽管 Adobe Systems 的 Flash 具有相同的优势。
- 无需部署 .NET 运行时即可执行 .NET 代码。Silverlight 插件确实包含精简的 .NET 运行时,但用户无需处理大量下载和 Windows 安装程序的复杂性,只需约 4MB 的小下载,所有这些都在浏览器中处理。到目前为止,根据我的经验,安装既顺利又容易。
- 性能很有希望。Silverlight 在这个质数计算器中表现出色,这无疑要归功于对本机代码的 JIT 编译,尽管它在渲染图形方面可能不那么好。
- 对 Moonlight 的支持意味着将会有 Silverlight 的官方开源实现,从而减轻专有方面的影响。
- Silverlight 直接解释 XAML,而 Adobe 的 XML GUI 语言 MXML 在编译时转换为 SWF。事实上,XAML 页面作为资源包含在用于部署 Silverlight 应用程序的已编译 .XAP 二进制文件中。.XAP 文件只是具有不同扩展名的 ZIP。这也意味着搜索引擎可以潜在地索引 Silverlight 应用程序中的文本,就像它们对 Flash 一样。
- 第三方组件供应商已经非常熟悉 Silverlight 附加组件。例如,Infragistics、ComponentOne 和 DevExpress。
- 使您的 .NET 代码跨平台。随着 Mac 无处不在,将 Visual Basic 或 C# 代码迁移到跨平台、基于浏览器的 Silverlight 客户端的能力将越来越有用。显然,这仅适用于现有的 .NET 开发人员 - 我猜这是 Silverlight 的主要市场,但它是一个很大的市场。这同样适用于下一点:
- 使用 Visual Studio。Microsoft 的 IDE 是一个成熟且广受欢迎的开发环境,而且由于它也是 ASP.NET 的工具,因此您可以将它用于服务器端代码以及 Silverlight 客户端。对于不熟悉 Visual Studio 的人,Silverlight SDK 还支持命令行编译。
- 选择你的语言。对多种语言的支持从一开始就是 .NET 的一部分,在 Silverlight 2.0 中拥有 .NET 运行时意味着您可以使用 C#、Visual Basic 或动态语言运行时 (DLR) Iron Ruby 编写客户端逻辑或铁蟒。
- 隔离存储为 Silverlight 应用程序提供本地文件访问,但仅限于特定于应用程序的受保护位置,提供了一种相对安全的方式来获得此好处。
The cons
缺点
- If Apple won't even allow Flash on the iPhone, what chance is there for Silverlight?
- Silverlight is late to the game. Flash is mature, well trusted and ubiquitous. Silverlight 2 only comes out of beta in the Autumn (we hope). It is the version we care about - the one that includes the .NET runtime - and will still lack support on mobile devices, even Windows Mobile, though this is promised at some unspecified later date.
- The design tools are Expression Blend and Expression Design - but who uses them? The design world uses Adobe PhotoShop.
- While having solution compatibility between Expression Blend and Visual Studio sounds good, it's actually a hassle having to use two separate tools, especially when there are niggling incompatibilities, as in the current beta.
- No support for the popular H.264 video codec. Instead hi-def video for Silverlight must be in VC-1, which is less common.
- It's another effort to promote proprietary technology rather than open standards.
- Yes Linux will be supported via Moonlight, but when? It seems likely that the Linux implementation will always lag behind the Windows and Mac releases.
- Silverlight supports SOAP web services, or REST provided you don't use PUT or DELETE, but doesn't have an optimized binary protocol like Adobe's ActionScript Message Format (AMF), which likely means slower performance in some scenarios.
- Silverlight is a browser-only solution, whereas Flash can be deployed for the desktop using Adobe Integrated Runtime (AIR). Having said that, yes I have seen this.
- You have to develop on Windows. This is particularly a problem for the Expression design tools, since designers have a disproportionately high number of Macs.
- 如果 Apple 甚至不允许在 iPhone 上使用 Flash,那么 Silverlight 又有什么机会呢?
- Silverlight 迟到了。Flash 已经成熟、值得信赖且无处不在。Silverlight 2 仅在秋季推出测试版(我们希望如此)。这是我们关心的版本——包含 .NET 运行时的版本——并且仍然缺乏对移动设备的支持,甚至是 Windows Mobile,尽管这是在某个未指定的日期承诺的。
- 设计工具是 Expression Blend 和 Expression Design - 但谁使用它们?设计界使用 Adobe PhotoShop。
- 虽然 Expression Blend 和 Visual Studio 之间的解决方案兼容性听起来不错,但实际上必须使用两个单独的工具很麻烦,尤其是当存在细微的不兼容性时,例如在当前测试版中。
- 不支持流行的 H.264 视频编解码器。相反,Silverlight 的高清视频必须使用 VC-1,这不太常见。
- 这是促进专有技术而非开放标准的另一项努力。
- 是的,Moonlight 将支持 Linux,但什么时候支持?Linux 实现似乎总是落后于 Windows 和 Mac 版本。
- Silverlight 支持 SOAP Web 服务或 REST,前提是您不使用 PUT 或 DELETE,但没有优化的二进制协议,如 Adobe 的 ActionScript 消息格式 (AMF),这可能意味着在某些情况下会降低性能。
- Silverlight 是仅限浏览器的解决方案,而 Flash 可以使用 Adobe Integrated Runtime (AIR) 部署到桌面。话虽如此,是的,我已经看到了这一点。
- 你必须在 Windows 上开发。对于 Expression 设计工具来说,这尤其是一个问题,因为设计人员拥有不成比例的大量 Mac。
回答by IgorK
PROs vs. ASP.NET Web Forms
PRO 与 ASP.NET Web 窗体
- No ViewState or "surprise crap" o This applies to Silverlight as well. Silverlight brings the "desktop" experience to the end user and there is no ViewState that is used in Silverlight.
- Faster server-side & client-side o Silverlight is faster on the client/server side depending on how you look at it. Silverlight is compiled in a .NET subsystem of Silverlight. You have access to multithreading, LINQ, complex data structures, etc. The performance vs. an ASP.NET or AJAX/JavaScript application is it magnitudes times better because of the client execution and some of the items that normally are handled in a server BLL can be brought down to the client
- Simplified model for multiple related views o Silverlight supports the complete seperation of the data and the UI. Taking this further by just creating seperate views for say another consumer of Silverlight is pretty powerful. You can apply the same MVC/MVP pattern inside Silverlight and attain this level of abstraction. Jason mentions an example of being able to create a seperate view for an iPhone and only the View component has to change. This applies to Silverlight as well for different things. For example, I have large sized Silverlight app I want to port to SharePoint. I can create a "Smaller View" for SharePoint so it fits nicer into the UI. Furthermore, Silverlight Mobile is being private tested now. I would assume that same very powerful level of abstraction applies as well to create a "Mobile view" for your Silverlight application.
- Unit Testable o Silverlight includes a Unit Test framework as well. It can be downloaded here: http://code.msdn.microsoft.com/silverlightut/
- Challenges if you are not running IIS 7 o Silverlight does NOT care if you are not running on IIS 6 or IIS 7 or Apache for that matter. This is one feature where Silverlight has an advantage over ASP.NET MVC.
- Client Caching o In ASP.NET Web Forms or MVC, you are caching on the server. Silverlight allows you to cache on the client via Isolated Storage (which can be increased to hundreds of megs if necessary). This allows applications to perform ultra fast without bogging down the hosting server.
- 没有 ViewState 或“惊喜废话” o 这也适用于 Silverlight。Silverlight 为最终用户带来了“桌面”体验,并且 Silverlight 中没有使用 ViewState。
- 更快的服务器端和客户端 o Silverlight 在客户端/服务器端更快,这取决于您如何看待它。Silverlight 是在 Silverlight 的 .NET 子系统中编译的。您可以访问多线程、LINQ、复杂数据结构等。 与 ASP.NET 或 AJAX/JavaScript 应用程序相比,由于客户端执行和一些通常在服务器 BLL 中处理的项目,它的性能要好几倍可以被带到客户端
- 多个相关视图的简化模型 o Silverlight 支持数据和 UI 的完全分离。通过创建单独的视图来进一步说明这一点,例如 Silverlight 的另一个使用者非常强大。您可以在 Silverlight 中应用相同的 MVC/MVP 模式并获得这种抽象级别。Jason 提到了一个能够为 iPhone 创建单独视图的示例,并且只有视图组件必须更改。这也适用于 Silverlight 以及不同的事情。例如,我想要移植到 SharePoint 的大型 Silverlight 应用程序。我可以为 SharePoint 创建一个“小视图”,使其更适合 UI。此外,Silverlight Mobile 现在正在接受私人测试。我认为同样非常强大的抽象级别也适用于创建“移动视图”
- 可单元测试 o Silverlight 还包括一个单元测试框架。可以在这里下载:http: //code.msdn.microsoft.com/silverlightut/
- 如果您没有运行 IIS 7 的挑战 o Silverlight 并不关心您是否运行在 IIS 6、IIS 7 或 Apache 上。这是 Silverlight 优于 ASP.NET MVC 的一项功能。
- 客户端缓存 o 在 ASP.NET Web 窗体或 MVC 中,您在服务器上进行缓存。Silverlight 允许您通过独立存储(如有必要,可以增加到数百兆)在客户端上进行缓存。这允许应用程序以超快的速度执行,而不会使托管服务器陷入困境。
CONs vs. ASP.NET Web Forms
CON 与 ASP.NET Web 窗体
- Difficult to convert existing code o Silverlight is a completely different programming platform than either ASP.NET WebForms or MVC. Not only will a lot of the code not convert, you also have to think about the client layer and in most cases a complete re-architecture is needed if you are replacing large modules inside your existing ASP.NET site.
- NOT the best SEO out of the box o Google several months ago started spidering SWF files and adding them to the search engine. I think Silverlight is probably still a ways away here. What you can do for Silverlight SEO is the basic tricks to describe the meta data tags really well around the plug in.
- Data access o Data access in Silverlight is limited to Web Services/WCF/ADO.NET Data Services. You cannot make direct calls via ADO.NET or stored procedures to a database.
- Security o Silverlight runs on the client. A lot of your bits are then roaming in the wild on the internet. Furthermore, some of the data access techniques do not support full WS* standard security. Therefore, beyond certificate based transport security, you are either writing a lot of your own plumbing code or waiting for the next rev. The XAML code is pretty much insecure; not many applications have their Intellectual Property in their UI. In Silverlight, that can be very easily reverse engineered using Silverlight Spy for example. Silverlight, just by nature, is a little less secure than an ASP.NET MVC application. Obviously, you would want to encrypt/obfuscate your Silverlight assemblies before letting them off in the wild.
- 难以转换现有代码 o Silverlight 是一个与 ASP.NET WebForms 或 MVC 完全不同的编程平台。不仅很多代码不会转换,您还必须考虑客户端层,并且在大多数情况下,如果您要替换现有 ASP.NET 站点中的大型模块,则需要完整的重新架构。
- 不是最好的 SEO 开箱即用 o 谷歌几个月前开始抓取 SWF 文件并将它们添加到搜索引擎中。我认为 Silverlight 可能还有很长的路要走。您可以为 Silverlight SEO 做的是基本技巧,可以很好地描述插件周围的元数据标签。
- 数据访问 o Silverlight 中的数据访问仅限于 Web 服务/WCF/ADO.NET 数据服务。您不能通过 ADO.NET 或存储过程直接调用数据库。
- 安全性 o Silverlight 在客户端上运行。然后你的很多东西都在互联网上漫游。此外,某些数据访问技术不支持完整的 WS* 标准安全性。因此,除了基于证书的传输安全之外,您要么编写大量自己的管道代码,要么等待下一次修订。XAML 代码非常不安全;没有多少应用程序在其 UI 中拥有自己的知识产权。例如,在 Silverlight 中,可以很容易地使用 Silverlight Spy 对其进行逆向工程。Silverlight 就本质而言,不如 ASP.NET MVC 应用程序安全。显然,您希望在将 Silverlight 程序集公开之前对其进行加密/混淆处理。
回答by John Rusk
Isn't click once available on firefox these days, via this addon: https://addons.mozilla.org/en-US/firefox/addon/1608
这些天,通过此插件在 Firefox 上单击一次可用:https: //addons.mozilla.org/en-US/firefox/addon/1608
回答by Peter Gfader
1. Silverlight can access the DOM from the hosting pageand
2. the hosting page can access the Silverlight part.
That's a big + for Silverlight
1. Silverlight可以从托管页面访问DOM和
2托管页面可以访问Silverlight的一部分。
这是 Silverlight 的一大优势
But all other limitations cry for WPF/Windows-Forms with Clickonce
file access, right mouse click, ease of db access
但是所有其他限制都适用于具有 Clickonce文件访问、鼠标右键单击、数据库访问方便的WPF/Windows-Forms