双重部署WPF应用程序本机和XBAP [英] Dual-deploying a WPF app natively and as a XBAP

查看:202
本文介绍了双重部署WPF应用程序本机和XBAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建可以部署为XBAP或本机Windows应用程序的WPF应用程序,尽可能少的开销? XBAP与WPF Windows应用程序二进制兼容,并且运行在相同的CLR(与Silverlight不同)之上。他们在某些方面仍然有所不同。

How to create a WPF application that can be deployed as either a XBAP or as a native Windows application with as little overhead as possible? XBAPs are binary compatible with WPF Windows applications and run on top of the same CLR (Unlike Silverlight). They still differ in some ways.

从部署的角度来看,XBAP的最大区别在于,一个Windows控件作为主容器,而Windows应用程序具有Window控件。使Windows应用程序使用页面控件,但感觉(随意不同意)在Windows应用程序中使用页面导航方法是非常直观的,这是相当微不足道的。

From deployment point of view their largest difference is that a XBAP has a Page control as the main container while a Windows application has a Window control. It would be rather trivial to make the Windows application use the Page control but I feel (Feel free to disagree) that using a Page navigation method in a Windows application is rather unintuitive.

第二个主要区别是默认情况下XBAP在部分受信任的环境中执行。这可以绕过,XBAP可以完全信任模式运行。使用XBAP的部分信任模式意味着您无法直接访问XBAP中的远程Web服务或本机代码。

The second major difference is that XBAPs by default are executed in a partially trusted environment. This can be bypassed though and the XBAPs can be made run in full trust mode. The partial trust mode with XBAPs means you cannot access for example remote web services or native code from the XBAPs directly.

实现以下功能的简单易维护方式是什么?以上问题?

What would be an easy and maintainable way to achieve the following with the above issues?

要求



  1. 显示来自远程Web服务器(如flickr或通过非托管API)的信息。

  2. 如果可能,部署方法应该保持忠实于他们的平台。也就是说:在Windows应用程序中使用XBAP中的页面,这些都是有意义的。

限制


  1. 平台优化。 XBAP所需的东西不应影响Windows客户端,反之亦然。

  2. 部署选项尽可能多地共享代码。这有助于测试和维护。

  3. 运行XBAP应尽可能简单。证书预先要求将会破坏XBAP的目的。

我收集的是第一个要求需要两个单独的项目。可以通过拥有包含所有UI并由两个部署项目引用的用户控制项目来处理第二个限制。 WCF Web服务可以解决XBAP的局限性。

What I have gathered is that first requirement requires two separate projects. The second restriction could be worked upon by having a user control project which contains all the UI and is referenced by the two deployment projects. A WCF web service could work around the limitations of XBAPs.

如果使用类似于上述行的解决方案,第一个限制将需要一些工作,因为Windows客户端可以无需WCF服务已经以完全信任模式运行。此外,第三个要求将需要一些部署特定的代码,所以所有的UI代码都不能在用户控制项目中。

If employing a solution similar to the above lines the first restriction would require some work as the Windows client could do without the WCF service as it's already running in full trust mode. Also the third requirement would need some deployment specific code so all the UI code cannot be in the user control project.

我想知道可以使用哪些解决方案解决这些问题。随意忽略部分解决方案。这里主要是为了解释这一点,并防止已经有思想的意见。所以只是为了澄清,我对这个问题的所有解决方案感兴趣,而不仅仅是那些遵守部分解决方案的解决方案。

I'd like to know what solutions could be used to resolve these problems. Feel free to ignore the partial solution. It's there mainly to explain the point and to prevent the "Thought of this already" comments. So just to clarify, I'm interested in all solutions to this problem, not just those that abide to the partial solution.

原因感兴趣的是,解决方案将意味着WPF Windows应用程序和XBAP之间无需考虑,因为这两者都可以通过更多的努力创建,客户端可以选择最适合他们的。

The reason for interest to this is that a solution would mean there's no need to ponder between a WPF Windows app and a XBAP as these both could be created with little more effort and the client could choose whichever suits them best.

推荐答案

你可能想看看Prism(在codeplex
它有助于以最小的代码更改来定位Wpf,Xbap和Silverlight(额外的工作量取决于您的项目)。

You may want to take a look at Prism (at codeplex) It helps to target Wpf, Xbap and Silverlight with minimum code changes (the amount of extra work depends on your project).

以下是如何使用它创建Wpf和Xbap应用程序:棱镜和XBap应用程序

Here's how to use it to create Wpf and Xbap application: Prism and XBap Applications

这篇关于双重部署WPF应用程序本机和XBAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆