开发者

Bundle .NET 3.5 libs with app, so it runs on machines with only .NET 2.0 installed?

I want to use LINQ on machines with only .NET Framework 2.0 installed.

I've alread read about LINQBri开发者_JAVA百科dge. But can't I simply set "copy local" to the referenced assemblies like System.Core.dll and System.Xml.Linq.dll to get the functionality I need?

Are there any drawbacks? Is this even allowed?


.Net 3.5 is really just .Net 2.0 with some extra dlls. There is no 3.5 runtime. If you include the dlls you need, the application will run without any problems.

From the following article concerning the linq bridge comment: http://www.albahari.com/nutshell/linqbridge.aspx

First, it's important to understand that C# 3.0 and Framework 3.5 are designed to work with CLR 2.0—the same CLR version that Framework 2.0 uses. This means that the C# 3.0 compiler emits IL code that runs on the same virtual machine as before.

This makes Framework 3.5 additive—just as Framework 3.0 was additive—comprising additional assemblies that enhance the existing 2.0 Framework and CLR. So there's nothing to stop us from writing our own assemblies that do the work of Framework 3.5 (at least, the critical bits required for local LINQ queries).

The compiler then looks for Where, OrderBy and Select methods. The critical thing is that it can find appropriately named methods with the correct signatures (typically extension methods). But it doesn't matter what assembly the methods come from. LINQBridge simply provides another source of these methods—that are functionally identically to those implemented in the Framework 3.5 assemblies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜