Silverlight 和普通 .NET Framework 之间的 CLR 差异?
是否有任何编写需要与 Silverlight 兼容的库的汇总指南?
或者只是构建、查找错误、修复、重复的标准流程?
显然,我认识到答案可能取决于目标 Silverlight 的版本,但如果解决方案是特定的,我希望任何答案都只指定版本。
说明:基本上,我希望该库适用于普通的 CLR 和 Silverlight,而不引用任何 Silverlight 特定的库。如果它需要引用此类库才能在 Silverlight 中工作,那么我更喜欢使用条件编译并生成专门的构建。理想情况下,它会正常工作,因为我可以选择两者功能的子集。
有这方面的明确资源吗?我主要是在寻找一个列出了需要注意的常见事项的网站。基本上是积极主动的,而不是仅仅在采取方法后寻找问题。
Are there any aggregated guides to writing libraries which need to be Silverlight-compatible?
Or is the standard procedure to just build, look for errors, fix, repeat?
Obviously I recognize the answer may depend on what version of Silverlight is being targeted, but I'd expect any answer to just specify version if the solution is specific.
Clarification: Basically I want the library to work for both plain-old CLR and Silverlight and not reference any Silverlight specific libs. If it needs to reference such libs in order for it to work in Silverlight, then I'd prefer use conditional compilation and produce a specialized build. Ideally it would just work as I could pick a subset of functionality of the two.
Are there any definitive resources for this? I'm mostly looking for a website which lists common things to watch out for. Basically proactive rather than just looking for issues after an approach is taken.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的意思是在 Silverlight 项目和常规 CLR 项目之间共享代码吗?在这种情况下,我通常将代码编写为 Silverlight 项目,以确保我不会使用其中不可用的任何功能。只要您远离 Gui 组件,您的代码也将与 .Net 兼容。
可以从 .Net 4 运行时引用 Silverlight 4 程序集。这里你有同样的情况,但你只需要编译你的程序集的一个版本。
Do you mean to share code between a Silverlight project and a regular CLR project? In that case I usually write the code as a Silverlight project to make sure I don't use any features not available there. As long as you stay away from the Gui components your code will be compatible with .Net as well.
It is possible to reference Silverlight 4 assemblies from the .Net 4 runtime. Here you have the same situation, but you only need to compile one version of your assembly.
创建社区 wiki 以获取有关此主题的资源链接。 (仍在搜索标准 CLR 和 Silverlight CLR 之间的 API 增量列表。)
使用相同代码定位多个 CLR:
Silverlight 完全运行在不同版本的 CLR 上,与标准 CLR 二进制不兼容。所以你实际上无法构建一个同时针对这两个目标的库。但是,您可以使用完全相同的代码文件来针对每个环境构建。
(或者,如果您小心处理条件属性,您也可以在单个 .csproj 中执行相同的操作。)
WPF 和 Silverlight 之间的差异2.0:
WPF 和 Silverlight 1.1 之间的差异:
Windows 和 Macintosh 上的 Silverlight 差异:
Windows Phone 上 Silverlight 的差异:
还有一个变体是Silverlight 的 Windows Phone 实现。
Starting a community wiki for links to resources on this topic. (Still searching for a list of API delta between standard CLRs and Silverlight CLRs.)
Targeting multiple CLRs with the same code:
Silverlight fully runs on a different version of the CLR which is binary incompatible with the standard CLR. So you literally cannot build a library which targets both. However, you can use the exact same code files for both built targeting each environment.
(Alternatively you can do the same thing a single .csproj if you are careful with your conditional attributes.)
Differences Between WPF and Silverlight 2.0:
Differences Between WPF and Silverlight 1.1:
Silverlight Differences on Windows and Macintosh:
Differences in Silverlight on Windows Phone:
Yet another variation is the Windows Phone implementation of Silverlight.