本文介绍了在一个项目中编译Silverlight和WPF的最佳实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚完成了一个Silverlight项目,是时候进行一些清理了.我想将我的核心文件放入一个单独的项目中,我将从主要的Silverlight应用程序中引用该文件.其中一些类与WPF兼容,我非常希望能够在一个项目中全部包含Silverlight/WPF代码.我理想的解决方案是允许多个配置的单个项目.所以,

I've just completed a Silverlight project and it's time to have a little clean up. I'd like to take my core files and put them into a separate project which I will reference from my main Silverlight app.Some of these classes are compatible with WPF and I would quite like to be able to have Silverlight / WPF code all in one project. My ideal solution would be a single project that allows multiple configurations. So,

配置:Silverlight将生成:Company.Controls.Silverlight.dll

Configuration: Silverlight would generate:Company.Controls.Silverlight.dll

配置:WPF将生成:Company.Controls.Wpf.dll

Configuration: WPF would generate:Company.Controls.Wpf.dll

是否可以通过定义将同一文件中的相同源分开?

Is it possible to have the same source in the same file just seperated via defines?

有人做过吗?

编辑:我已经为每个项目(例如MyCompany.Windows.Controls)创建了一个解决方案,该解决方案随后包含2个项目,即MyCompany.Windows.Controls& MyCompany.Windows.Controls.Silverlight.除了这两个文件夹外,我还有一个共享"文件夹,其中包含两个项目都使用的文件.到目前为止效果很好:)

I've created a solution per project, like MyCompany.Windows.Controls, which then contains 2 projects, MyCompany.Windows.Controls & MyCompany.Windows.Controls.Silverlight. Alongside those 2 folders I have a "Shared" folder, which contains files used by both projects. It works well so far :)

推荐答案

我自己还没有尝试过(仍然想找时间玩Silverlight),但是不能为两个项目提供一个解决方案,一个定位到Silverlight,另一个定位到.NET 3.5,然后将通用类文件作为链接添加到每个项目中(右键单击该项目,添加现有项...,添加为链接)?

I haven't tried it myself (still trying to find the time to play with Silverlight), but couldn't you have one solution with two projects, one targetting Silverlight and the other targetting .NET 3.5, and add the common class files to each project as Links (right-click the project, Add Existing Item..., Add as Link)?

**更新:有关项目链接器,请参见下面Mark的回答.我在PRISM 2.0 CAL的多目标复合应用程序中一直使用它,这是一件很漂亮的事情.我认为这在PRISM 1.0中不存在吗?

** Update: See Mark's answer below regarding the Project Linker. I've been using this in my multi-targetted composite application with the PRISM 2.0 CAL and it's a beautiful thing. I don't think this existed in PRISM 1.0?

这篇关于在一个项目中编译Silverlight和WPF的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 16:04