从 .NET 1.1 升级到 .NET 2.0,会发生什么?

发布于 2024-07-04 07:39:46 字数 260 浏览 7 评论 0原文

我正在开发一个大型 .NET 1.1 项目,并且希望对其进行升级,主要是为了能够使用 Visual Studio 2008 等更好的工具,但也是因为 .NET 中的新功能和少量错误2.0框架。

该项目大部分由 VB.NET 组成,但也有部分由 C# 组成。 它是一个 Windows 窗体应用程序,使用各种第三方控件。 使用 .NET 远程处理,富客户端可以与与 MSSQL 2000 数据库交互的服务器进程进行对话。

如果我们决定执行升级,会出现哪些问题?

I'm working on a big .NET 1.1 project, and there exists a wish to upgrade this, majorily to be able to use better tools like Visual Studio 2008, but also because of the new features and smaller amount of bugs in the .NET 2.0 framework.

The project consist for the bigger part of VB.NET, but there are also parts in C#. It is a Windows Forms application, using various third party controls. Using .NET remoting the rich client talks to a server process which interfaces with a MSSQL 2000 database.

What kind of issues can we expect in case we decide to perform the upgrade?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

半岛未凉 2024-07-11 07:39:46

.Net 2.0 中的主题模型发生了变化,线程中未处理的异常将导致整个应用程序终止。 我在更新一个执行大量线程并且偶尔崩溃的应用程序时遇到了这个问题。 显然 .Net 2.0 模型更强大,因为无论如何您肯定应该捕获这些,但这是我在进行迁移时遇到的唯一真正问题。

这篇文章讲述了一切:
http://odetocode.com/blogs/scott/archive/2005 /12/14/2618.aspx

There is a change to the theading model in .Net 2.0 onwards where unhandled exceptions in a thread will cause the whole app to terminate. I ran into this when updating an app that did lots of threading and occasionally crashed. Obviously the .Net 2.0 model is more robust as you should certainly be catching these anyway, but it was the only really issue I came across when making the migration.

This article talks all about it:
http://odetocode.com/blogs/scott/archive/2005/12/14/2618.aspx

恋你朝朝暮暮 2024-07-11 07:39:46

Tobi,我们现在正在考虑进行相同的迁移。 首先,您可以通过制作项目(或其一部分)的副本并通过 .NET 2.0 编译器对其进行“试运行”来充分了解预期的结果。 我的经验是,2.0 编译器会给出更多关于不良编程实践的警告,而 1.1 编译器却忽略了这一点。 编译器会警告您有关隐式转换、“不明确”返回路径(函数不返回值的代码路径)以及其他一些小问题。

以下是一些可能对您有用的链接:
.NET Framework 兼容性

.NET Framework 2.0 中的重大更改的 Word 文档

We're looking at doing the same migration right now Tobi. First, you can get a good idea of what to expect by making a copy of your project (or a portion of it) and give it a "dry run" through the .NET 2.0 compiler. My experience with this was that the 2.0 compiler gives more warnings about bad programming practices that the 1.1 compiler let slide. The compiler will warn you about implicit casts, "ambiguous" return paths (a code path where a function doesn't return a value), and some other minor things.

Here's a few links that you might find helpful:
.NET Framework Compatability

Word Document of Breaking changes in .NET Framework 2.0

孤单情人 2024-07-11 07:39:46

真的没什么。 您会发现一些关于过时方法的编译警告,但通常这些警告很容易修复。

你应该把目标放大,选择 3.5。 这里的水是冰的。

Nothing, really. You'll find a couple warnings on compilation about obsolete methods, but often those are trivial to fix.

You should shoot big and go for 3.5. The water is niiiiiiice in here.

零時差 2024-07-11 07:39:46

查看有关将 .NET 2.0 应用程序演进到 3.5 的白皮书。 我认为1.1到2.0的变化比较显着,但是过程应该是类似的。

Take a peek at this whitepaper on evolving a .NET 2.0 application to 3.5. I hold that the changes from 1.1 to 2.0 are more significant, but the process should be similar.

泪是无色的血 2024-07-11 07:39:46

除了上面提到的应用程序配置内容之外,如果您使用任何 XSD 验证,您将需要替换一些有关加载和验证 XML 的代码。

In addition to the app configuration stuff mentioned above, if you use any XSD validation you will need to replace some code around loading and validating XML.

寒尘 2024-07-11 07:39:46

如果您使用 app.config 来存储程序设置,您将看到最多的编译警告。 System.Configuration.ConfigurationManager 已弃用 1.1 配置类。

您可能会看到来自编译器的其他警告是针对未初始化的变量(在变量声明中将它们设置为“= Nothing”或“= null;”以使它们消失)和未使用的变量(编译器确定它们是可以安全删除)。

The most compilation warnings you'll see are if you use app.config to store program settings. The 1.1 configuration class was deprecated for System.Configuration.ConfigurationManager.

Other warnings you may see coming from the compiler will be for uninitialized variables (set them to "= nothing" or "= null;" in the variable declaration to make them go away), and unused variables (the compiler is sure they're safe to delete).

冧九 2024-07-11 07:39:46

除了一些关于某些内容已过时的警告之外,大多数代码仍然应该可以编译。

但对于 Visual Studio 生成的代码,您应该注意一些事项。

如果您在 Visual Studio 2003 中生成了强类型数据集,您就可以忘记在较新版本的 Visual Studio 中编辑它们。 您必须重建它们,或者最好用 nHibernate 之类的东西替换它们,以获得最终的 OR-mapper-bliss

表单设计器应该仍然使用旧表单。 不过,您可能会感到有些困惑,因为 2005 和 2008 在这里使用了部分类。 因此,如果您创建新表单,代码看起来与旧表单不同。
我从未升级过 ASP.Net 应用程序,所以我不了解 Web 表单,但我想它的工作方式与 winforms 的东西相同。 大多数情况下它会起作用,但预计会有一些设计师的怪异。

Most of the code should still compile except for a few warnings about stuff being obsolete.

But there are a couple of things you should look out for with respect to Visual Studio generated code.

If you've generated strongly typed datasets in Visual Studio 2003 you can forget about editing them in newer versions of visual studio. You'll have to rebuild them or better just replace them with something like nHibernate for ultimate OR-mapper-bliss

The designer for forms should still work with old forms. You can get some confusion though because 2005 and 2008 use partial classes here. So if you create new forms the code looks different from the old ones.
I have never upgraded an ASP.Net application so I don't know about web-forms but I guess it will work the same as winforms stuff. Mostly it will work but expect some designer weirdness.

悲念泪 2024-07-11 07:39:46

.NET 1.1 和 .NET 2.0-3.5 是完全不同的框架,更重要的是,.NET 3.5 只是一组可以添加到 .NET 2.0 项目中的额外程序集 - 就核心程序集而言,实际上没有任何更改我知道 - 升级后的编译器知道称为 LINQ 的语法糖、扩展方法等。

换句话说,我不认为 .NET 2.0-3.5 升级与 .NET 1.1-2.0 升级非常相似。

.NET 1.1 and .NET 2.0-3.5 are entirely different frameworks, and more importantly, .NET 3.5 is just a set of extra assemblies you can add to your .NET 2.0 project - none of the core assemblies actually got changed, as far as I'm aware - and an upgraded compiler that knows about the syntax sugar called LINQ, extension methods, etc.

In other words, I do not think a .NET 2.0-3.5 upgrade is very similar to a .NET 1.1-2.0 upgrade.

小…红帽 2024-07-11 07:39:46

事情可能会顺利编译,但我们在年初升级的应用程序遇到了一些令人讨厌的运行时问题。

首先,当从 2.0 应用程序调用 1.1 Web 服务时,我们在 DateTime 对象中的时区处理方面遇到了许多问题,因为序列化到线路时与 UTC 的转换似乎在框架版本之间的工作方式不同。

此外,2.0 异步 Web 服务使用基于事件的 klutzy 机制,而不是 IAsyncResult 模式,如果您要批量处理请求,这将是一个巨大的痛苦。

最后,我们有一些使用 Microsoft.mshtml.dll 托管嵌入式浏览器的遗留代码。 升级到 2.0 导致应用程序默默地切换到该 dll 的较新版本,该版本更改了一些与 javascript 交互相关的行为。 最后一个案例有点晦涩难懂,但表明迁移到较新的运行时可能会对您可能进行的任何 COM 交互产生影响。

希望这可以帮助!

Things will probably compile OK, but we had a few nasty runtime issues with an application we upgraded at the start of the year.

First, we had a number of problems with timezone handling in DateTime objects when calling 1.1 webservices from a 2.0 application, as the conversions to and from UTC when serializing to the wire appeared to work differently between framework versions.

Also, 2.0 async webservices use the klutzy event-based mechanism instead of the IAsyncResult pattern, which is a royal pain if you are batching your requests.

Finally, we had some legacy code that hosted an embedded browser using Microsoft.mshtml.dll. Upgrading to 2.0 caused the application to silently switch to a newer version of that dll, which had some changed behaviour related to javascript interaction. This last one is a bit of an obscure case, but shows that moving to the newer runtime may have implications for any COM interaction you might have.

Hope this helps!

雄赳赳气昂昂 2024-07-11 07:39:46

我们处理电子邮件的方式必须改变。 1.1版本使用system.WEB.mail,

    Imports System.Web.Mail
    '
    Dim message As New MailMessage' this is a web.mail msg, not a net.mail msg
    Dim objConn As SmtpMail
    Dim objAttach As MailAttachment
        '
    message .From = "[email protected]"
       ' more properties assigned to objMail
    objAttach = New MailAttachment(ExportName)
    message.Attachments.Add(objAttach)
       ' Here's where we actually send the thing
    SmtpMail.SmtpServer.Insert(0, "127.0.0.1")
    objConn.Send(objMail)

新版本有system.NET.mail

         Imports System.Net.Mail
        '
         Dim message as MailMessage ' this is a net.mail msg, not a web.mail msg
         Dim data As Attachment
        Dim client As New SmtpClient("127.0.0.1")
    '
        data = New Attachment(ExportName)
    ' Create the message and add the attachment
        message = New MailMessage(EmailFrom, EmailTo, reportDescription)
        message.Attachments.Add(data)
' Send the message
        client.Send(message)

The way we were doing email had to change. The 1.1 version used system.WEB.mail, with

    Imports System.Web.Mail
    '
    Dim message As New MailMessage' this is a web.mail msg, not a net.mail msg
    Dim objConn As SmtpMail
    Dim objAttach As MailAttachment
        '
    message .From = "[email protected]"
       ' more properties assigned to objMail
    objAttach = New MailAttachment(ExportName)
    message.Attachments.Add(objAttach)
       ' Here's where we actually send the thing
    SmtpMail.SmtpServer.Insert(0, "127.0.0.1")
    objConn.Send(objMail)

and the new one has system.NET.mail

         Imports System.Net.Mail
        '
         Dim message as MailMessage ' this is a net.mail msg, not a web.mail msg
         Dim data As Attachment
        Dim client As New SmtpClient("127.0.0.1")
    '
        data = New Attachment(ExportName)
    ' Create the message and add the attachment
        message = New MailMessage(EmailFrom, EmailTo, reportDescription)
        message.Attachments.Add(data)
' Send the message
        client.Send(message)
鸠魁 2024-07-11 07:39:46

RESX 文件升级问题

注意国际化的 RESX 文件。

当您在 .net 2.0 中重新打开 .net 1.1 表单时,RESX 文件将升级到新版本。 在 .net 1.1 中,外语 .resx 文件仅包含更改。 在 .net 2.0 中,默认 .resx 文件中的所有字段现在都移至外语 resx 文件中。 (例如 .fr.resx)。 如果您已经将表单国际化,则必须查看所有外语 resx 文件。

国际化工具

您可能使用/自己编写的一些用于集体国际化的工具可能不再起作用,因为它们可能使用了编号的资源。 (Multi Lang & Infragistics)

Infragistics Winforms 控件修改.net 1.1 中的InitializeForm() 并使用资源编号系统访问资源。 迁移到 .net 2.0 时,由于重新生成 resx 文件,Infragistics 资源的编号将失败。 您将需要升级您的 Infragistics 库。

RESX files upgrade problems

Watch out for internationalized RESX files.

When you reopen a ,net 1.1 form in .net 2.0 the RESX file gets upgraded to a new version. In .net 1.1 the foreign language .resx file only contained the changes. In .net 2.0 ALL of the fields in the default .resx file now get moved into the foreign language resx file. (.fr.resx for example). If you have already internationalized the form all of the foreign language resx files will have to be looked at.

Internationalisation Tools

Some tools that you may have used/written yourself to do internationalization en mass may not work anymore as they may have used numbered resources. (Multi Lang & Infragistics)

Infragistics Winforms controls modify the InitializeForm() in .net 1.1 and access resources using a resource numbering system. When migrated to .net 2.0 the numbering of the Infragistics resources will fail as the resx file is regenerated. You will need to upgrade your Infragistics libraries.

风筝有风,海豚有海 2024-07-11 07:39:46

尽管您可能会收到一些已弃用的方法警告,但您可能不会遇到任何破坏性问题。 编译器通常应该告诉您替换是什么。 我知道一些 System.Configuration 内容已更新。

You probably won't have any breaking issues, though you may get some deprecated method warnings. The compiler should generally tell you what the replacement is though. I know that some of the System.Configuration things were updated.

混浊又暗下来 2024-07-11 07:39:46

不应该有太多问题,因为理论上它是向后兼容的(我注意到 MikeeMike 关于线程异常的评论)。 迁移之后,您会发现有很多不错的东西,例如泛型。 尽管您不想一次性将所有集合移植到泛型,但一旦完成此操作,由于转换次数减少,您的代码应该更可靠 - 并且可能更快(尽管在这方面可能会有所不同) 。 目前我即将启动 .NET 2 -> 我的三个产品的 .NET 4 转换。 主要优点是多线程支持的进一步改进(并行 foreach 循环等)。

There shouldn't be too much of a problem as in theory it is backward compatible (I note MikeeMike's comment about thread exceptions). After the move, you'll fine there are quite a few nice things like generics. Although you don't want to port all your collections to generics in one fell swoop, once you've done this your code should be more reliable due to the reduced number of casts - and probably quicker (although mileage may vary in this aspect). At the moment I'm about to start the .NET 2 -> .NET 4 conversion of three of my products. The main advantage will be the further improvements in multi-threaded support (parallel foreach loops, etc).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文