公司新闻

第三方API和包映射支持.NET升级助手

发布 2024年七月1日
分享:

.NET升级助手

如果您曾经需要将应用程序升级到较新版本的 .NET,那么您可能对 .NET Upgrade Assistant(.NET 升级助手)并不陌生。这个来自微软的强大工具让项目升级过程变得简单明了--至少对微软库和框架来说是这样。对于外部服务来说,升级到新版本仍然是一个手动且耗时的过程。

现在不用了! .NET Upgrade Assistant(.NET 升级助手)本身刚刚获得了巨大的升级。上个月,微软宣布为其工具提供第三方 API 和软件包地图支持,允许开发人员共享自己的地图,使用户在更新到新框架时更容易替换过时的第三方 API 和软件包。

新增的第三方 API 支持为集成 API 提供了一种标准化的方法,而软件包映射则如其所言--它映射了应用程序中使用的所有软件包,使更新依赖关系变得更简单,并提高了项目的整体稳定性。

更换图书馆从未如此简单

在本次更新之前,如果您的应用程序依赖于外部服务,升级到较新版本的 .NET 或更改框架是很困难的。这意味着要手动查找等效的 API 和包,而在此之前,您还得担心如何更新代码中的所有类型和方法。正如微软在其公告中解释的那样

以 Xamarin.Forms.Color 为例。您不仅需要将命名空间从 Xamarin.Forms 更新为 Microsoft.Maui.Graphics,还需要将 R、G 或 B 等属性更改为 Red、Green 或 Blue,而 AliceBlue 等静态颜色属性现在属于名为 Colors 的新类型。

现在,开发人员可以像微软使用其自有库一样创建自己的映射,这些令人头疼的问题已经成为过去。不仅是更新库,.NET Upgrade Assistant 现在还可以用来一并更改库。

将 Iron Software 产品集成到您的应用程序中一直都很简单,但从其他库切换到 Iron Software 就不那么简单了。但现在,有了自定义映射和 API 支持,使用全新的库升级应用程序比以往任何时候都要简单。让我们来看看用 IronPDF 和 PDFsharp 创建一个简单 PDF 的代码:

IronPDF

using IronPdf;
var htmlToPdf = new HtmlToPdf();
var pdf = htmlToPdf.RenderHtmlAsPdf("<html><body><h1>Hello, IronPDF!</h1></body></html>");
pdf.SaveAs("ironpdf_example.pdf");
using IronPdf;
var htmlToPdf = new HtmlToPdf();
var pdf = htmlToPdf.RenderHtmlAsPdf("<html><body><h1>Hello, IronPDF!</h1></body></html>");
pdf.SaveAs("ironpdf_example.pdf");
Imports IronPdf
Private htmlToPdf = New HtmlToPdf()
Private pdf = htmlToPdf.RenderHtmlAsPdf("<html><body><h1>Hello, IronPDF!</h1></body></html>")
pdf.SaveAs("ironpdf_example.pdf")
VB   C#

PDFsharp

using PdfSharp.Pdf;
class Program
{
   static void Main()
   {
       // Create a new PDF document
       PdfDocument document = new PdfDocument();
       // Add a page to the document
       PdfPage page = document.AddPage();
       // Obtain a graphics object to draw on the page
       XGraphics gfx = XGraphics.FromPdfPage(page);
       // Draw "Hello, PDFsharp!" on the page
       gfx.DrawString("Hello, PDFsharp!", new XFont("Arial", 12), XBrushes.Black,
           new XRect(10, 10, page.Width, page.Height), XStringFormats.TopLeft);
       // Save the document to a file
       document.Save("output.pdf");
       // Close the document
       document.Close();
   }
}
using PdfSharp.Pdf;
class Program
{
   static void Main()
   {
       // Create a new PDF document
       PdfDocument document = new PdfDocument();
       // Add a page to the document
       PdfPage page = document.AddPage();
       // Obtain a graphics object to draw on the page
       XGraphics gfx = XGraphics.FromPdfPage(page);
       // Draw "Hello, PDFsharp!" on the page
       gfx.DrawString("Hello, PDFsharp!", new XFont("Arial", 12), XBrushes.Black,
           new XRect(10, 10, page.Width, page.Height), XStringFormats.TopLeft);
       // Save the document to a file
       document.Save("output.pdf");
       // Close the document
       document.Close();
   }
}
Imports PdfSharp.Pdf
Friend Class Program
   Shared Sub Main()
	   ' Create a new PDF document
	   Dim document As New PdfDocument()
	   ' Add a page to the document
	   Dim page As PdfPage = document.AddPage()
	   ' Obtain a graphics object to draw on the page
	   Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
	   ' Draw "Hello, PDFsharp!" on the page
	   gfx.DrawString("Hello, PDFsharp!", New XFont("Arial", 12), XBrushes.Black, New XRect(10, 10, page.Width, page.Height), XStringFormats.TopLeft)
	   ' Save the document to a file
	   document.Save("output.pdf")
	   ' Close the document
	   document.Close()
   End Sub
End Class
VB   C#

正如您所看到的,切换库可能会对代码造成大量改动,耗费大量时间和精力,还可能降低应用程序的稳定性。但现在,我们可以半自动地更改命名空间、类型和方法,让您轻松升级项目。

Iron Software 和 .NET 齐头并进

.NET升级助手的这一新更新使第三方开发人员能够始终站在技术的最前沿,使他们的应用程序与.NET Core和其他框架的最新版本保持同步。在 Iron Software,兼容性一直是我们产品的重中之重。我们支持多年前的 .NET Core、Standard 和 Framework 版本,无论客户使用何种设置,我们都能提供业界领先的软件。但现在,您可以在不影响稳定性或功能的情况下将应用程序升级到更新的版本,我们将与您并肩作战。

我们对 .NET Upgrade Assistant 的更新感到非常兴奋。如果您是开发人员,有兴趣使用该工具更新 Iron 软件支持的应用程序,请与我们联系,我们将为您提供帮助。! 至于其他人,请继续关注软件包地图,它们将改善您的工作流程和项目。

Iron 软件产品的终身许可证价格低至 749 美元起 (包括一年的免费支持,因此我们可以帮助指导您使用这些新工具更新应用程序).您可以从我们的 30 天免费试用版开始,我们的软件还可以完全免费用于开发目的--因此您可以真正了解它的功能。如果您想享受更多优惠,请查看 Iron Suite,您可以用两个工具的价格获得全部九个 Iron 软件工具。快乐编码!

< 前一页
超越代码:IronPDF为您的业务带来的优势
下一步 >
介绍IronWord:用于Word文档编辑的C# DOCX库