简体   繁体   English

我可以将对System.Core.dll(.net 3.5)的引用添加到.net 2.0应用程序并使用它吗

[英]Can I add a reference to System.Core.dll (.net 3.5) to a .net 2.0 application and use it

Can I add a reference to System.Core.dll (.net 3.5) to a .net 2.0 application and use it 我可以将对System.Core.dll(.net 3.5)的引用添加到.net 2.0应用程序并使用它吗

I am trying to use the TimeZoneInfo class which is available in .net 3.5 only, by referencing System.Core.dll 我试图通过引用System.Core.dll使用仅在.net 3.5中可用的TimeZoneInfo类

Alternatively, is their an alternate for TimeZoneInfo in .net 2.0 (or a customised class) 或者,它们是.net 2.0(或自定义类)中TimeZoneInfo的替代者吗?

No you really should not . 不,你真的不应该 You must install 3.5 on the target machine or you will run into unpredictable behavior in the running program. 必须在目标计算机上安装3.5,否则您将在正在运行的程序中遇到无法预料的行为。 The 3.5 framework including System.Core.dll depend on several bug fixes / features that were added to CLR 2.0 SP1 (this is a part of 3.5 framework). 包括System.Core.dll在内的3.5框架取决于CLR 2.0 SP1中添加的若干错误修复/功能(这是3.5框架的一部分)。 If you run against an unpatched CLR you will be essentially running untested code and will likely hit several bugs. 如果您在未打补丁的CLR上运行,则您实际上将在运行未经测试的代码,并且可能会遇到几个错误。

Scott Hanselman wrote a blog post describing how to run an early version of MVC on the 2.0 framework. Scott Hanselman 写了一篇博客文章,描述了如何在2.0框架上运行MVC的早期版本。 He noted that the dependencies on System.Core will probably be OK as long as you are very careful not to call any routines that depend on CLR features specific to 3.0+ (for example, LINQtoSQL). 他指出,System.Core程序的依赖性可能会是OK,只要你是非常小心,不要打电话给依赖于CLR例程的任何的特定功能3.0+(例如,LINQtoSQL)。

He rightly plastered the blog post with disclaimers that it is not supported, it very well might not work for you, but he got it to work and if you can, then yay for you. 正确地贴满了博客文章与免责声明,它被支持,它很可能已经不适合你的工作,但他它得到的工作,如果可以的话,那么耶为您服务。

I'm not sure if you can do this with System.Core.dll, but we have done this before with the Linq2Sql dlls for a .net 2.0 application. 我不确定是否可以使用System.Core.dll来执行此操作,但是我们之前已经使用.net 2.0应用程序的Linq2Sql dll来执行此操作。 .net 3.5 uses the same version of the CLR with new assemblies built upon the .net 2.0 runtime. .net 3.5将相同版本的CLR与基于.net 2.0运行时建立的新程序集一起使用。 If you can get all of the dependencies, it might work. 如果可以获取所有依赖项,则它可能会起作用。 As I said, this worked for us with Linq2Sql dlls, but is not guaranteed for all scenarios. 就像我说的那样,这对我们使用Linq2Sql dll有用,但不能保证在所有情况下都适用。 (For example, you probably wont be able to get WPF to run on Windows 2000, but you might be able to get Linq to Objects to work) (例如,您可能无法使WPF在Windows 2000上运行,但是您可能能够使Linq to Objects正常工作)

You can do this, currently doing the same thing for a tool for work - also to utilize the TimeZoneInfo stuff. 您可以执行此操作,当前在工作工具上也做同样的事情-还可以利用TimeZoneInfo东西。 As long as thats all you're using you shouldn't run into any issues (at least I haven't). 只要多数民众赞成在使用,您就不会遇到任何问题(至少我没有)。

However I'm not entirely sure of the legalities of bundling System.Core with your app. 但是,我不太确定将System.Core与您的应用捆绑在一起的合法性。 From what I know you're not allowed to. 据我了解,你是不允许的。

I ended up utilizing the one from Mono for the tool that uses it. 我最终将Mono中的一个用于使用它的工具。

.net 3.5 runs on .net 2.0 runtime. .net 3.5在.net 2.0运行时上运行。 So you should be able to use it... But referencing a single dll would lead to unexpected behaviour as you don't know all the dependencies system.core.dll have.... I would recommend not to do that... 因此,您应该能够使用它。但是引用单个dll会导致意外行为,因为您不知道system.core.dll的所有依赖项。...我建议不要这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM