双部署WPF应用程序本身作为一个XBAP作为一个、应用程序、WPF、XBAP

2023-09-03 15:17:25 作者:与你为伍

如何创建可部署无论是作为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应用程序中使用页面的控制,但我觉得(随意不同意),使用页面导航方法在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服务或本地code。

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?

要求

部署在两个方面:一个XBAP通过HTTP和作为一个独立的WPF执行 显示从远程Web服务器,如Flickr,或通过非托管API的信息。 如果可能,部署方法应该忠于自己的平台。这就是说:使用页面中XBAP,其中的意义和对话框在Windows应用程序,其中的道理

限制

平台进行了优化。由XBAP所需要的东西,不应该影响Windows客户端,反之亦然。 在部署选项分享尽可能多的code越好。这有助于在测试和维护。 运行XBAP应尽可能地简单。证书prerequirement会破坏一个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服务,因为它是已经在完全信任模式下运行。另外,第三个要求就需要一些特定应用的code,这样所有的UI code不能在用户控件项目。

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.

我想知道哪些解决方案可以用来解决这些问题。随意忽略的部分解决方案。它的存在主要是为了说明的一点和prevent评论这已经想到。所以,只是为了澄清,我感兴趣的是所有解决这个问题,而不仅仅是遵守的部分解决方案。

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.

推荐答案

您可能想看一看棱镜(的在codePLEX ) 它有助于针对WPF,XBAP和Silverlight以最小的code的变化(额外的工作量取决于您的项目)。

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