针对这两个.NET 3.5和Silverlight [英] Targeting both .NET 3.5 and Silverlight

查看:93
本文介绍了针对这两个.NET 3.5和Silverlight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们想象一下,我已经有一个项目建设的.NET 3.5程序集。现在我想建立这个组件Silverlight的,而且,保持其Silverlight的版本,以最小的努力进一步提高。

Let's imagine I already have a project building .NET 3.5 assembly. Now I want to build this assembly for Silverlight, and moreover, maintain its Silverlight version with minimal efforts further.

什么是不能接受的:

  • 创建单独的项目为Silverlight构建

什么是可以接受的:

  • 添加自定义指令允许我对例如目标无论是Silverlight的或.NET依赖性MSBuild的属性。
  • 添加特殊构建配置为Silverlight
  • 添加的#ifdef的Silverlight / #ENDIF部分的源$ C ​​$ C。
  • 的.csproj /的.cs一般来说任何其他修改。

因此​​,基本上,我想保持一个项目,而是针对两个框架。我不想维护两个独立的项目,因为这可能会导致错误,类似于忘记包括一个新的文件。如果有很多项目和大的团队,这是非常重要的,以排除这样的错误。

So basically, I'd like to maintain a single project, but target two frameworks. I don't want to maintain two separate projects, because this may lead to mistakes like forgetting to include a new file. If there are many project and big team, this is really important to exclude such mistakes.

如果这是完全不可能的,提供类似福利的任何解决方案是可以接受的。

If this is completely impossible, any solution providing similar benefits is acceptable.

推荐答案

你也排除了从Silverlight项目链接到你的项目里面的文件?这是一个相当普遍的方法来共享Silverlight和完整的CLR之间的实现。 <一href="http://pagebrooks.com/archive/2008/10/11/sharing-$c$c-between-.net-and-silverlight-platforms.aspx">Sharing $ C $ .NET和Silverlight平台℃之间

Have you also ruled out linking to the files inside the your project from a Silverlight project? That's a fairly common approach to sharing an implementation between Silverlight and the full CLR. Sharing Code Between .NET and Silverlight Platforms

另外,根据贾斯汀天使可以引用并使用一个Silverlight类库从完整的CLR。我没有尝试这样做我自己,并留下一些悬而未决的问题,但它确实使场景简单:<一href="http://silverlight.net/blogs/justinangel/archive/2008/12/29/using-silverlight-dlls-on-the-desktop.aspx">http://silverlight.net/blogs/justinangel/archive/2008/12/29/using-silverlight-dlls-on-the-desktop.aspx

Also, according to Justin Angel you can reference and use a Silverlight class library from the full CLR. I haven't tried this myself, and it leaves some questions unanswered, but it does make the scenario straightforward: http://silverlight.net/blogs/justinangel/archive/2008/12/29/using-silverlight-dlls-on-the-desktop.aspx

这篇关于针对这两个.NET 3.5和Silverlight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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