公司新聞

Iron Software產品與Visual Studio 2026:完整整合指南

介紹

2025年11月11日發佈的Visual Studio 2026標誌著現代軟體開發的一個重要里程碑,引入了Microsoft所稱的首個"AI原生智能開發環境"。Visual Studio 2026帶來了性能的改進、新的界面與Fluent UI設計系統一致,並全面支持.NET 10和C# 14。對於使用Iron Software的.NET函式庫套件(包括IronPDF、IronOCR、IronBarcode和IronXL)工作的開發人員來說,這個最新版本提供了一個絕佳機會,將最先進的開發工具與強大的文件處理能力相結合。

根據Cosmin Vladutu在Medium上的文章,開發人員對Visual Studio 2026的性能提升印象深刻,指出"版本構建速度比2022更快,記憶體使用量從2022年的1200到1300 MB降低到800到900 MB左右。"這種性能改進為使用處理複雜操作的文件處理庫創造了理想的環境。

在這份全面指南中,我們將探討Iron Software完整產品系列如何與Visual Studio 2026無縫整合,展示實際代碼範例並強調這個強大組合對於在各種編程語言和框架中工作的.NET開發人員的好處。

Visual Studio 2026:適用於.NET開發人員的主要功能

Visual Studio 2026

使用Fluent UI設計系統增強的IDE體驗

Visual Studio 2026推出了一個全新設計的用戶體驗,界面與Microsoft的Fluent UI設計系統一致。 新功能包括增強的編輯器控制、改進的視覺清晰度,以及對整體IDE主題的更多控制。 開發人員現在可以選擇11個新的色調主題,允許更大程度的自定義編碼環境以匹配個人偏好並減少長時間開發會話中的眼睛疲勞。

現代設定體驗取代了傳統的工具>選項對話框,提供了一個精簡的用戶友好界面。 這種重新設計的用戶體驗使得.net開發人員無論是在開發網頁應用程式、命令行界面工具還是Enterprise Edition專案時,都能迅速配置其開發環境。

Elanchezhiyan P在Medium上指出的那樣,IDE的特點是在"Fluent UI重新設計中具有更清晰的佈局與圖標",使開發體驗更加直觀和吸引眼球。

GitHub Copilot整合與AI驅動開發

GitHub Copilot Chat

Visual Studio 2026最大改進之一是整個IDE中的深度Copilot整合。剖析器Copilot代理可以分析CPU使用、記憶體分配和運行時行為,提供更好的Copilot回應和Copilot見解幫助開發人員優化其代碼。 Copilot輔助擴展到開發的各個方面,包括測試檢視器,開發人員可以利用AI自動生成並修復單元測試。

新的右鍵菜單提供了快速訪問Copilot操作的功能,自適應粘貼功能會自動調整粘貼的代碼以適應專案的上下文。 這些功能代表了一種朝向AI驅動的開發的基本轉變,智能建議幫助開發人員更快速地編碼,不會犧牲代碼質量。

性能改進和建構工具

Visual Studio 2026在所有方面提供了大幅度的性能改進。 具有數百個現有專案的解決方案現在比Visual Studio 2022載入速度快40%。當使用F5時,調試器顯示啟動時間最多快30%,由於IDE和.NET 10運行時兩者的優化,完整重建感覺更接近於增量建設。

建構工具已與IDE本身分離,這意味著開發人員可以用自動月度更新來更新Visual Studio,而不影響他們的.NET或C++編譯器。 這種分離確保了持續集成工作流程的穩定,同時開發人員可以從IDE的最新功能和錯誤修復中受益。

代碼覆蓋和測試增強

Visual Studio 2026的一個重大突破是首次在Visual Studio社群版和專業版中提供代碼覆蓋。之前僅限於企業版,開發人員現在可以分析代碼覆蓋結果窗口以了解其代碼的哪個部分被測試單元運行。 測試工具的民主化幫助更多的開發人員確保他們的應用程式在部署之前經過充分測試。

選擇分析代碼覆蓋選項允許開發人員直接從測試菜單運行選定的測試代碼覆蓋,結果顯示在代碼覆蓋窗口中,顯示每個程序集、類和方法的百分比。 Visual Studio直接在代碼編輯器中突出顯示已測試的行,讓人很容易識別出測試覆蓋空白。

Iron Software產品:.NET 10兼容性確認

Iron Software首頁

在深入研究實施細節之前,重要的是要確認所有Iron Software產品完全支持.NET 10,這是Visual Studio 2026的主要框架版本。根據Iron Software官網,所有產品—包括IronPDF、IronOCR、IronBarcode、IronXL、IronWord、IronPPT、IronQR、IronZIP、IronPrint和IronWebScraper—完全支持.NET 10、9、8、7、6、Framework、Core及Azure部署。

這種全面的兼容性確保了開發人員可以在使用Iron Software的文件處理庫同時受益最新版本的Visual Studio 2026。 這些程式庫支持包括C#、VB.NET和F#在內的各種編程語言,使更廣泛的.NET開發社群可以訪問。

IronPDF:PDF生成與操作在Visual Studio 2026中

IronPDF首頁

開始使用IronPDF

IronPDF是一個全面的C# PDF程式庫,允許開發員在.NET專案中創建、編輯和提取PDF內容。 隨著Visual Studio 2026對.NET 10和增強的除錯能力的支持,使用IronPDF變得更加高效。

要在您的Visual Studio 2026專案中安裝IronPDF,打開NuGet Package Manager Console並運行:

Install-Package IronPdf
Install-Package IronPdf
SHELL

或使用.NET CLI:

dotnet add package IronPdf
dotnet add package IronPdf
SHELL

學習更多關於IronPDF安裝

HTML到PDF轉換

IronPDF最強大的功能之一是將HTML轉換為PDF,這在Visual Studio 2026的增強編碼環境中無縫運作。 這裡有一個實用的範例:

using IronPdf;

// Create a new PDF from HTML string
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello from Visual Studio 2026!</h1><p>Generated with IronPDF</p>");

// Save the PDF
pdf.SaveAs("output.pdf");
using IronPdf;

// Create a new PDF from HTML string
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello from Visual Studio 2026!</h1><p>Generated with IronPDF</p>");

// Save the PDF
pdf.SaveAs("output.pdf");
Imports IronPdf

' Create a new PDF from HTML string
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello from Visual Studio 2026!</h1><p>Generated with IronPDF</p>")

' Save the PDF
pdf.SaveAs("output.pdf")
$vbLabelText   $csharpLabel

生成的PDF

簡單的HTML到PDF輸出

隨著Visual Studio 2026的內聯返回值功能和性能除錯功能,開發員可以在不逐步檢查代碼的情況下實時查看RenderHtmlAsPdf方法的返回值。 Copilot見解還可以提供優化PDF生成操作的建議。

探索HTML到PDF轉換以及我們豐富的文件和 教程中的不同形式的HTML IronPDF可以呈現成PDF文件。

工作與現有PDF

IronPDF允許您輕鬆操作現有的PDF文档。 Visual Studio 2026中增強的編輯器控制使書寫此代碼顯得更加直觀:

using IronPdf;

// Open an existing PDF
var pdf = PdfDocument.FromFile("existing.pdf");

// Add watermark
pdf.ApplyWatermark("<h2 style='color:red'>CONFIDENTIAL</h2>", 30, VerticalAlignment.Middle, HorizontalAlignment.Center);

// Extract text
string text = pdf.ExtractAllText();
Console.WriteLine(text);

// Save modified PDF
pdf.SaveAs("modified.pdf");
using IronPdf;

// Open an existing PDF
var pdf = PdfDocument.FromFile("existing.pdf");

// Add watermark
pdf.ApplyWatermark("<h2 style='color:red'>CONFIDENTIAL</h2>", 30, VerticalAlignment.Middle, HorizontalAlignment.Center);

// Extract text
string text = pdf.ExtractAllText();
Console.WriteLine(text);

// Save modified PDF
pdf.SaveAs("modified.pdf");
Imports IronPdf

' Open an existing PDF
Dim pdf = PdfDocument.FromFile("existing.pdf")

' Add watermark
pdf.ApplyWatermark("<h2 style='color:red'>CONFIDENTIAL</h2>", 30, VerticalAlignment.Middle, HorizontalAlignment.Center)

' Extract text
Dim text As String = pdf.ExtractAllText()
Console.WriteLine(text)

' Save modified PDF
pdf.SaveAs("modified.pdf")
$vbLabelText   $csharpLabel

用Visual Studio Community 2026修改的PDF

用水印修改的PDF

Visual Studio 2026中新的剖析器啟動體驗使得識別處理大型PDF文件時的性能瓶頸變得輕而易舉。 開發員可以使用benchmarkdotnet專案模板測量和優化PDF操作。

PDF表單和數位簽署

IronPDF支持PDF表單數位簽署,對於需要文件驗證的企業版本應用程式至關重要:

using IronPdf;
using IronPdf.Signing;

// Open a PDF with form fields
var pdf = PdfDocument.FromFile("form.pdf");

// Fill form fields
pdf.Form.Fields["Name"].Value = "John Developer";
pdf.Form.Fields["Email"].Value = "john@example.com";

// Sign the PDF (using CSP-based certificates)
var signature = new PdfSignature("certificate.pfx", "password");
pdf.Sign(signature);

// Save the signed PDF
pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;

// Open a PDF with form fields
var pdf = PdfDocument.FromFile("form.pdf");

// Fill form fields
pdf.Form.Fields["Name"].Value = "John Developer";
pdf.Form.Fields["Email"].Value = "john@example.com";

// Sign the PDF (using CSP-based certificates)
var signature = new PdfSignature("certificate.pfx", "password");
pdf.Sign(signature);

// Save the signed PDF
pdf.SaveAs("signed.pdf");
Imports IronPdf
Imports IronPdf.Signing

' Open a PDF with form fields
Dim pdf = PdfDocument.FromFile("form.pdf")

' Fill form fields
pdf.Form.Fields("Name").Value = "John Developer"
pdf.Form.Fields("Email").Value = "john@example.com"

' Sign the PDF (using CSP-based certificates)
Dim signature = New PdfSignature("certificate.pfx", "password")
pdf.Sign(signature)

' Save the signed PDF
pdf.SaveAs("signed.pdf")
$vbLabelText   $csharpLabel

Visual Studio 2026中的代碼覆蓋特性幫助確保表單填寫和簽名邏輯在不同的場景中已得到妥善測試。

IronOCR:在Visual Studio 2026中的光學字符識別

IronOCR首頁

設定IronOCR

IronOCR使開發者能夠在.NET應用程式中執行OCR運作,支持超過125種語言。 在Visual Studio 2026中安裝IronOCR非常簡單:

Install-Package IronOcr
Install-Package IronOcr
SHELL

基本OCR操作

隨著Visual Studio 2026的複雜除錯工具和更好的Copilot回應,處理OCR變得更容易掌控:

using IronOcr;

// Initialize OCR engine
var ocr = new IronTesseract();

// Perform OCR on an image
using (var input = new OcrInput())
{
    input.AddImage("document.png");

    // Process the image
    var result = ocr.Read(input);

    // Extract text
    string text = result.Text;
    Console.WriteLine(text);

    // Get confidence level
    double confidence = result.Confidence;
    Console.WriteLine($"Confidence: {confidence}%");
}
using IronOcr;

// Initialize OCR engine
var ocr = new IronTesseract();

// Perform OCR on an image
using (var input = new OcrInput())
{
    input.AddImage("document.png");

    // Process the image
    var result = ocr.Read(input);

    // Extract text
    string text = result.Text;
    Console.WriteLine(text);

    // Get confidence level
    double confidence = result.Confidence;
    Console.WriteLine($"Confidence: {confidence}%");
}
Imports IronOcr

' Initialize OCR engine
Dim ocr As New IronTesseract()

' Perform OCR on an image
Using input As New OcrInput()
    input.AddImage("document.png")

    ' Process the image
    Dim result = ocr.Read(input)

    ' Extract text
    Dim text As String = result.Text
    Console.WriteLine(text)

    ' Get confidence level
    Dim confidence As Double = result.Confidence
    Console.WriteLine($"Confidence: {confidence}%")
End Using
$vbLabelText   $csharpLabel

控制台輸出

Visual Studio 2026中的OCR例輸出

Visual Studio 2026中的語法高亮使OCR代碼更具可讀性,而測試探索器集成使開發者能為OCR準確性撰寫完整的單元測試。

多語言 OCR 支持

IronOCR對多語言支持,完全適用於Visual Studio 2026的增強語言支持:

using IronOcr;

// Initialize with specific language
var ocr = new IronTesseract();
ocr.Language = OcrLanguage.Spanish;

// Add additional languages
ocr.AddSecondaryLanguage(OcrLanguage.French);

using (var input = new OcrInput())
{
    input.AddImage("multilingual-document.png");
    var result = ocr.Read(input);

    // Process multilingual text
    foreach (var page in result.Pages)
    {
        Console.WriteLine($"Page {page.PageNumber}: {page.Text}");
    }
}
using IronOcr;

// Initialize with specific language
var ocr = new IronTesseract();
ocr.Language = OcrLanguage.Spanish;

// Add additional languages
ocr.AddSecondaryLanguage(OcrLanguage.French);

using (var input = new OcrInput())
{
    input.AddImage("multilingual-document.png");
    var result = ocr.Read(input);

    // Process multilingual text
    foreach (var page in result.Pages)
    {
        Console.WriteLine($"Page {page.PageNumber}: {page.Text}");
    }
}
Imports IronOcr

' Initialize with specific language
Dim ocr As New IronTesseract()
ocr.Language = OcrLanguage.Spanish

' Add additional languages
ocr.AddSecondaryLanguage(OcrLanguage.French)

Using input As New OcrInput()
    input.AddImage("multilingual-document.png")
    Dim result = ocr.Read(input)

    ' Process multilingual text
    For Each page In result.Pages
        Console.WriteLine($"Page {page.PageNumber}: {page.Text}")
    Next
End Using
$vbLabelText   $csharpLabel

利用圖像增強進行OCR

IronOCR包含圖像增強能力以提高低質量掃描的OCR準確性:

using IronOcr;

var ocr = new IronTesseract();

using (var input = new OcrInput())
{
    // Add image with enhancement
    input.AddImage("poor-quality-scan.jpg");

    // Apply filters
    input.Deskew();
    input.DeNoise();
    input.Dilate();

    // Perform OCR
    var result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
using IronOcr;

var ocr = new IronTesseract();

using (var input = new OcrInput())
{
    // Add image with enhancement
    input.AddImage("poor-quality-scan.jpg");

    // Apply filters
    input.Deskew();
    input.DeNoise();
    input.Dilate();

    // Perform OCR
    var result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
Imports IronOcr

Dim ocr As New IronTesseract()

Using input As New OcrInput()
    ' Add image with enhancement
    input.AddImage("poor-quality-scan.jpg")

    ' Apply filters
    input.Deskew()
    input.DeNoise()
    input.Dilate()

    ' Perform OCR
    Dim result = ocr.Read(input)
    Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

Visual Studio 2026的內嵌if語句除錯功能幫助開發者精確了解哪些增強過濾器已應用及其對OCR結果的影響。

IronBarcode:條形碼與QR碼處理

IronBarcode首頁

安裝IronBarcode

IronBarcode為.NET應用程式提供全面的條形碼讀取與書寫功能:

Install-Package IronBarcode
Install-Package IronBarcode
SHELL

開始使用IronBarcode

從圖片讀取條形碼

Visual Studio 2026的文件IO工具使得處理包含條形碼的圖片文件變得簡單:

using IronBarCode;

// Read barcode from image file
var results = BarcodeReader.Read("barcode-image.png");

foreach (var result in results)
{
    Console.WriteLine($"Barcode Type: {result.BarcodeType}");
    Console.WriteLine($"Value: {result.Value}");
}
using IronBarCode;

// Read barcode from image file
var results = BarcodeReader.Read("barcode-image.png");

foreach (var result in results)
{
    Console.WriteLine($"Barcode Type: {result.BarcodeType}");
    Console.WriteLine($"Value: {result.Value}");
}
Imports IronBarCode

' Read barcode from image file
Dim results = BarcodeReader.Read("barcode-image.png")

For Each result In results
    Console.WriteLine($"Barcode Type: {result.BarcodeType}")
    Console.WriteLine($"Value: {result.Value}")
Next
$vbLabelText   $csharpLabel

IronBarcode控制台輸出

使用IronBarcode讀取條形碼的輸出信息

Visual Studio 2026的改善性能確保條形碼讀取操作能迅速執行,即使在批量處理多張圖片時。

生成條形碼

使用IronBarcode創建條形碼是直截了當的,Visual Studio 2026更新界面使得開發體驗舒適愉快:

using IronBarCode;
using IronSoftware.Drawing;

// Generate a QR code
var qrCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com", BarcodeEncoding.QRCode);

// Customize appearance
qrCode.SetMargins(10);
qrCode.AddBarcodeValueTextBelowBarcode();
qrCode.ChangeBarCodeColor(Color.Blue);

// Save as image
qrCode.SaveAsImage("qr-code.png");

// Or save as PDF
qrCode.SaveAsPdf("qr-code.pdf");
using IronBarCode;
using IronSoftware.Drawing;

// Generate a QR code
var qrCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com", BarcodeEncoding.QRCode);

// Customize appearance
qrCode.SetMargins(10);
qrCode.AddBarcodeValueTextBelowBarcode();
qrCode.ChangeBarCodeColor(Color.Blue);

// Save as image
qrCode.SaveAsImage("qr-code.png");

// Or save as PDF
qrCode.SaveAsPdf("qr-code.pdf");
Imports IronBarCode
Imports IronSoftware.Drawing

' Generate a QR code
Dim qrCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com", BarcodeEncoding.QRCode)

' Customize appearance
qrCode.SetMargins(10)
qrCode.AddBarcodeValueTextBelowBarcode()
qrCode.ChangeBarCodeColor(Color.Blue)

' Save as image
qrCode.SaveAsImage("qr-code.png")

' Or save as PDF
qrCode.SaveAsPdf("qr-code.pdf")
$vbLabelText   $csharpLabel

創建的QR碼

使用IronBarcode創建的QR碼

使用機器學習檢測進行高級條形碼閱讀

IronBarcode支持基於機器學習的檢測以提高準確性:

using IronBarCode;

// Configure barcode reader with ML detection
var options = new BarcodeReaderOptions
{
    ExpectMultipleBarcodes = true,
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
    CropArea = new System.Drawing.Rectangle(0, 0, 500, 500),
    UseCode39ExtendedMode = true
};

// Read barcodes with options
var results = BarcodeReader.Read("multi-barcode-image.png", options);

foreach (var barcode in results)
{
    Console.WriteLine($"Found: {barcode.BarcodeType} = {barcode.Value}");
}
using IronBarCode;

// Configure barcode reader with ML detection
var options = new BarcodeReaderOptions
{
    ExpectMultipleBarcodes = true,
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
    CropArea = new System.Drawing.Rectangle(0, 0, 500, 500),
    UseCode39ExtendedMode = true
};

// Read barcodes with options
var results = BarcodeReader.Read("multi-barcode-image.png", options);

foreach (var barcode in results)
{
    Console.WriteLine($"Found: {barcode.BarcodeType} = {barcode.Value}");
}
Imports IronBarCode
Imports System.Drawing

' Configure barcode reader with ML detection
Dim options As New BarcodeReaderOptions With {
    .ExpectMultipleBarcodes = True,
    .ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
    .CropArea = New Rectangle(0, 0, 500, 500),
    .UseCode39ExtendedMode = True
}

' Read barcodes with options
Dim results = BarcodeReader.Read("multi-barcode-image.png", options)

For Each barcode In results
    Console.WriteLine($"Found: {barcode.BarcodeType} = {barcode.Value}")
Next
$vbLabelText   $csharpLabel

Visual Studio 2026中的淨分配工具幫助開發者在處理大批量條形碼圖片時優化記憶體使用。

IronXL:不需要Office Interop的Excel文件處理

IronXL首頁

開始使用IronXL

IronXL允許開發者無需Microsoft Office或Excel Interop即可讀取、生成和編輯Excel文件:

開始使用IronXL

創建Excel工作簿

使用Visual Studio 2026的專案模板和改進的代碼編輯器來創建Excel文件變得輕而易舉:

using IronXL;

// Create a new Excel workbook
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.DefaultWorkSheet;

// Add data
sheet["A1"].Value = "Product";
sheet["B1"].Value = "Quantity";
sheet["C1"].Value = "Price";

// Add rows of data
sheet["A2"].Value = "IronPDF License";
sheet["B2"].Value = 1;
sheet["C2"].Value = 599;

sheet["A3"].Value = "IronOCR License";
sheet["B3"].Value = 1;
sheet["C3"].Value = 499;

// Add formula
sheet["C4"].Formula = "=SUM(C2:C3)";

// Save the workbook
workbook.SaveAs("products.xlsx");
using IronXL;

// Create a new Excel workbook
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.DefaultWorkSheet;

// Add data
sheet["A1"].Value = "Product";
sheet["B1"].Value = "Quantity";
sheet["C1"].Value = "Price";

// Add rows of data
sheet["A2"].Value = "IronPDF License";
sheet["B2"].Value = 1;
sheet["C2"].Value = 599;

sheet["A3"].Value = "IronOCR License";
sheet["B3"].Value = 1;
sheet["C3"].Value = 499;

// Add formula
sheet["C4"].Formula = "=SUM(C2:C3)";

// Save the workbook
workbook.SaveAs("products.xlsx");
Imports IronXL

' Create a new Excel workbook
Dim workbook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX)
Dim sheet As WorkSheet = workbook.DefaultWorkSheet

' Add data
sheet("A1").Value = "Product"
sheet("B1").Value = "Quantity"
sheet("C1").Value = "Price"

' Add rows of data
sheet("A2").Value = "IronPDF License"
sheet("B2").Value = 1
sheet("C2").Value = 599

sheet("A3").Value = "IronOCR License"
sheet("B3").Value = 1
sheet("C3").Value = 499

' Add formula
sheet("C4").Formula = "=SUM(C2:C3)"

' Save the workbook
workbook.SaveAs("products.xlsx")
$vbLabelText   $csharpLabel

創建的Excel文件輸出

Excel文件樣例輸出

Visual Studio 2026增強的語法高亮提供的視覺清晰度使得Excel操作代碼更易於閱讀和維護。

讀取現有的Excel文件

IronXL可以高效讀取現有Excel文件中的數據

using IronXL;

// Load existing Excel file
WorkBook workbook = WorkBook.Load("sales-data.xlsx");
WorkSheet sheet = workbook.GetWorkSheet("Sales");

// Read cells
foreach (var row in sheet.Rows)
{
    foreach (var cell in row)
    {
        Console.Write($"{cell.Value}\t");
    }
    Console.WriteLine();
}

// Access specific cell
var totalSales = sheet["D10"].DoubleValue;
Console.WriteLine($"Total Sales: ${totalSales:F2}");
using IronXL;

// Load existing Excel file
WorkBook workbook = WorkBook.Load("sales-data.xlsx");
WorkSheet sheet = workbook.GetWorkSheet("Sales");

// Read cells
foreach (var row in sheet.Rows)
{
    foreach (var cell in row)
    {
        Console.Write($"{cell.Value}\t");
    }
    Console.WriteLine();
}

// Access specific cell
var totalSales = sheet["D10"].DoubleValue;
Console.WriteLine($"Total Sales: ${totalSales:F2}");
Imports IronXL

' Load existing Excel file
Dim workbook As WorkBook = WorkBook.Load("sales-data.xlsx")
Dim sheet As WorkSheet = workbook.GetWorkSheet("Sales")

' Read cells
For Each row In sheet.Rows
    For Each cell In row
        Console.Write($"{cell.Value}" & vbTab)
    Next
    Console.WriteLine()
Next

' Access specific cell
Dim totalSales = sheet("D10").DoubleValue
Console.WriteLine($"Total Sales: ${totalSales:F2}")
$vbLabelText   $csharpLabel

控制台輸出

從現有Excel文件中提取的銷售數據

Visual Studio 2026中的零長度陣列分配優化有助於在讀取大型Excel文件時保證效率的記憶體使用。

使用Excel範圍和格式化

IronXL支持高級Excel操作,包括範圍樣式以及公式

using IronXL;

WorkBook workbook = WorkBook.Load(@"C:\Users\kyess\Desktop\Desktop\Code-Projects\Assets\financial_report.xlsx");
WorkSheet sheet = workbook.DefaultWorkSheet;

// Select a range
var range = sheet["A1:D1"];

range.Style.Font.Bold = true;
range.Style.Font.Height = 12; 
range.Style.SetBackgroundColor("#0066CC");
range.Style.Font.SetColor("#FFFFFF");

for (int i = 0; i <= 3; i++)
{
    sheet.AutoSizeColumn(i);
}

// Save changes
workbook.SaveAs("formatted-report.xlsx");
using IronXL;

WorkBook workbook = WorkBook.Load(@"C:\Users\kyess\Desktop\Desktop\Code-Projects\Assets\financial_report.xlsx");
WorkSheet sheet = workbook.DefaultWorkSheet;

// Select a range
var range = sheet["A1:D1"];

range.Style.Font.Bold = true;
range.Style.Font.Height = 12; 
range.Style.SetBackgroundColor("#0066CC");
range.Style.Font.SetColor("#FFFFFF");

for (int i = 0; i <= 3; i++)
{
    sheet.AutoSizeColumn(i);
}

// Save changes
workbook.SaveAs("formatted-report.xlsx");
Imports IronXL

Dim workbook As WorkBook = WorkBook.Load("C:\Users\kyess\Desktop\Desktop\Code-Projects\Assets\financial_report.xlsx")
Dim sheet As WorkSheet = workbook.DefaultWorkSheet

' Select a range
Dim range = sheet("A1:D1")

range.Style.Font.Bold = True
range.Style.Font.Height = 12
range.Style.SetBackgroundColor("#0066CC")
range.Style.Font.SetColor("#FFFFFF")

For i As Integer = 0 To 3
    sheet.AutoSizeColumn(i)
Next

' Save changes
workbook.SaveAs("formatted-report.xlsx")
$vbLabelText   $csharpLabel

樣式化的範例輸出

格式化的Excel工作表

與Visual Studio 2026功能集成

利用GitHub Copilot與Iron Software函式庫

使用Copilot生成工作代碼

Visual Studio 2026中深度的GitHub Copilot整合在使用Iron Software產品時提供智能代碼建議。 Copilot可以:

  • 從自然語言描述生成完整的IronPDF渲染代碼

  • 根據圖像質量建議最佳OCR設置

  • 推薦條形碼類型和編碼參數

  • 創建Excel公式和數據操作邏輯

簡單描述您希望達成的目標,Copilot將使用Iron Software函式庫生成相關代碼。 markdown編輯器支持也使得以範例記錄代碼變得簡單。

調試Iron Software應用程式

Visual Studio 2026增強的調試特性在處理文件處理時顯著提升了開發體驗:

using IronPdf;
using System.Diagnostics;

public class PdfProcessor
{
    public void ProcessDocument(string htmlContent, string outputPath)
    {
        // Visual Studio 2026 shows inline values here
        var renderer = new ChromePdfRenderer();

        // Inline if-statement debugging shows evaluation results
        if (string.IsNullOrEmpty(htmlContent))
        {
            throw new ArgumentException("HTML content cannot be empty");
        }

        // Inline post-return values show the PDF object immediately
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);

        // Copilot can analyze unexpected results
        var pageCount = pdf.PageCount;
        Debug.WriteLine($"Generated PDF with {pageCount} pages");

        pdf.SaveAs(outputPath);
    }
}
using IronPdf;
using System.Diagnostics;

public class PdfProcessor
{
    public void ProcessDocument(string htmlContent, string outputPath)
    {
        // Visual Studio 2026 shows inline values here
        var renderer = new ChromePdfRenderer();

        // Inline if-statement debugging shows evaluation results
        if (string.IsNullOrEmpty(htmlContent))
        {
            throw new ArgumentException("HTML content cannot be empty");
        }

        // Inline post-return values show the PDF object immediately
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);

        // Copilot can analyze unexpected results
        var pageCount = pdf.PageCount;
        Debug.WriteLine($"Generated PDF with {pageCount} pages");

        pdf.SaveAs(outputPath);
    }
}
Imports IronPdf
Imports System.Diagnostics

Public Class PdfProcessor
    Public Sub ProcessDocument(htmlContent As String, outputPath As String)
        ' Visual Studio 2026 shows inline values here
        Dim renderer = New ChromePdfRenderer()

        ' Inline if-statement debugging shows evaluation results
        If String.IsNullOrEmpty(htmlContent) Then
            Throw New ArgumentException("HTML content cannot be empty")
        End If

        ' Inline post-return values show the PDF object immediately
        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)

        ' Copilot can analyze unexpected results
        Dim pageCount = pdf.PageCount
        Debug.WriteLine($"Generated PDF with {pageCount} pages")

        pdf.SaveAs(outputPath)
    End Sub
End Class
$vbLabelText   $csharpLabel

內聯調試功能,與Copilot分析結合,使理解文件處理工作流程和快速識別問題變得很容易。

Iron Software的性能分析

Visual Studio 2026的剖析器Copilot代理可以分析使用Iron Software函式庫時的性能:

using IronPdf;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

[MemoryDiagnoser]
public class PdfBenchmarks
{
    private const string SampleHtml = "<html><body><h1>Test Document</h1></body></html>";

    [Benchmark]
    public void RenderSimplePdf()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(SampleHtml);
    }

    [Benchmark]
    public void RenderComplexPdf()
    {
        var renderer = new ChromePdfRenderer();
        var complexHtml = GenerateComplexHtml();
        var pdf = renderer.RenderHtmlAsPdf(complexHtml);
    }

    private string GenerateComplexHtml()
    {
        // Generate HTML with tables, images, etc.
        return "<html><body><table>...</table></body></html>";
    }
}

partial class Program
{
    static void Main(string[] args)
    {
        var summary = BenchmarkRunner.Run<PdfBenchmarks>();
    }
}
using IronPdf;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

[MemoryDiagnoser]
public class PdfBenchmarks
{
    private const string SampleHtml = "<html><body><h1>Test Document</h1></body></html>";

    [Benchmark]
    public void RenderSimplePdf()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(SampleHtml);
    }

    [Benchmark]
    public void RenderComplexPdf()
    {
        var renderer = new ChromePdfRenderer();
        var complexHtml = GenerateComplexHtml();
        var pdf = renderer.RenderHtmlAsPdf(complexHtml);
    }

    private string GenerateComplexHtml()
    {
        // Generate HTML with tables, images, etc.
        return "<html><body><table>...</table></body></html>";
    }
}

partial class Program
{
    static void Main(string[] args)
    {
        var summary = BenchmarkRunner.Run<PdfBenchmarks>();
    }
}
Imports IronPdf
Imports BenchmarkDotNet.Attributes
Imports BenchmarkDotNet.Running

<MemoryDiagnoser>
Public Class PdfBenchmarks
    Private Const SampleHtml As String = "<html><body><h1>Test Document</h1></body></html>"

    <Benchmark>
    Public Sub RenderSimplePdf()
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf(SampleHtml)
    End Sub

    <Benchmark>
    Public Sub RenderComplexPdf()
        Dim renderer = New ChromePdfRenderer()
        Dim complexHtml = GenerateComplexHtml()
        Dim pdf = renderer.RenderHtmlAsPdf(complexHtml)
    End Sub

    Private Function GenerateComplexHtml() As String
        ' Generate HTML with tables, images, etc.
        Return "<html><body><table>...</table></body></html>"
    End Function
End Class

Partial Class Program
    Shared Sub Main(ByVal args As String())
        Dim summary = BenchmarkRunner.Run(Of PdfBenchmarks)()
    End Sub
End Class
$vbLabelText   $csharpLabel

使用Visual Studio 2026中的benchmarkdotnet專案模板創建性能測試,並利用剖析器識別優化機會。

雲服務整合

Iron Software產品與從Visual Studio 2026部署的雲服務無縫運作:

using Microsoft.Azure.Functions;
using IronPdf;
using IronOcr;

public class DocumentProcessor
{
    [FunctionName("ConvertHtmlToPdf")]
    public async Task<IActionResult> ConvertToPdf(
        [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req)
    {
        string html = await new StreamReader(req.Body).ReadToEndAsync();

        // Configure IronPDF for Azure
        License.LicenseKey = Environment.GetEnvironmentVariable("IRONPDF_LICENSE");

        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(html);

        return new FileContentResult(pdf.BinaryData, "application/pdf")
        {
            FileDownloadName = "document.pdf"
        };
    }

    [FunctionName("ExtractTextFromImage")]
    public async Task<IActionResult> ExtractText(
        [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req)
    {
        var imageBytes = await ReadImageBytes(req);

        License.LicenseKey = Environment.GetEnvironmentVariable("IRONOCR_LICENSE");

        var ocr = new IronTesseract();
        using (var input = new OcrInput())
        {
            input.AddImage(imageBytes);
            var result = ocr.Read(input);

            return new OkObjectResult(new { text = result.Text });
        }
    }
}
using Microsoft.Azure.Functions;
using IronPdf;
using IronOcr;

public class DocumentProcessor
{
    [FunctionName("ConvertHtmlToPdf")]
    public async Task<IActionResult> ConvertToPdf(
        [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req)
    {
        string html = await new StreamReader(req.Body).ReadToEndAsync();

        // Configure IronPDF for Azure
        License.LicenseKey = Environment.GetEnvironmentVariable("IRONPDF_LICENSE");

        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(html);

        return new FileContentResult(pdf.BinaryData, "application/pdf")
        {
            FileDownloadName = "document.pdf"
        };
    }

    [FunctionName("ExtractTextFromImage")]
    public async Task<IActionResult> ExtractText(
        [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req)
    {
        var imageBytes = await ReadImageBytes(req);

        License.LicenseKey = Environment.GetEnvironmentVariable("IRONOCR_LICENSE");

        var ocr = new IronTesseract();
        using (var input = new OcrInput())
        {
            input.AddImage(imageBytes);
            var result = ocr.Read(input);

            return new OkObjectResult(new { text = result.Text });
        }
    }
}
Imports Microsoft.Azure.Functions
Imports IronPdf
Imports IronOcr
Imports System.IO
Imports Microsoft.AspNetCore.Mvc
Imports Microsoft.AspNetCore.Http
Imports System.Threading.Tasks

Public Class DocumentProcessor

    <FunctionName("ConvertHtmlToPdf")>
    Public Async Function ConvertToPdf(
        <HttpTrigger(AuthorizationLevel.Function, "post")> req As HttpRequest) As Task(Of IActionResult)

        Dim html As String = Await New StreamReader(req.Body).ReadToEndAsync()

        ' Configure IronPDF for Azure
        License.LicenseKey = Environment.GetEnvironmentVariable("IRONPDF_LICENSE")

        Dim renderer As New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf(html)

        Return New FileContentResult(pdf.BinaryData, "application/pdf") With {
            .FileDownloadName = "document.pdf"
        }
    End Function

    <FunctionName("ExtractTextFromImage")>
    Public Async Function ExtractText(
        <HttpTrigger(AuthorizationLevel.Function, "post")> req As HttpRequest) As Task(Of IActionResult)

        Dim imageBytes = Await ReadImageBytes(req)

        License.LicenseKey = Environment.GetEnvironmentVariable("IRONOCR_LICENSE")

        Dim ocr As New IronTesseract()
        Using input As New OcrInput()
            input.AddImage(imageBytes)
            Dim result = ocr.Read(input)

            Return New OkObjectResult(New With {.text = result.Text})
        End Using
    End Function

    Private Async Function ReadImageBytes(req As HttpRequest) As Task(Of Byte())
        Using memoryStream As New MemoryStream()
            Await req.Body.CopyToAsync(memoryStream)
            Return memoryStream.ToArray()
        End Using
    End Function

End Class
$vbLabelText   $csharpLabel

Visual Studio 2026的擴展雲服務支持使得將Iron Software驅動應用程式部署到Azure變得簡單直接。

在Visual Studio 2026中測試Iron Software應用程式

單元測試與代碼覆蓋

Visual Studio 2026的社群版與專業版中的代碼覆蓋功能允許對Iron Software整合進行透徹測試:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using IronPdf;
using System.IO;

[TestClass]
public class PdfGenerationTests
{
    [TestMethod]
    public void TestSimpleHtmlToPdf()
    {
        // Arrange
        var renderer = new ChromePdfRenderer();
        var html = "<h1>Test</h1>";

        // Act
        var pdf = renderer.RenderHtmlAsPdf(html);

        // Assert
        Assert.IsNotNull(pdf);
        Assert.IsTrue(pdf.PageCount > 0);
        Assert.IsTrue(pdf.BinaryData.Length > 0);
    }

    [TestMethod]
    public void TestPdfExtraction()
    {
        // Arrange
        var html = "<html><body><p>Sample text for extraction</p></body></html>";
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(html);

        // Act
        var extractedText = pdf.ExtractAllText();

        // Assert
        Assert.IsTrue(extractedText.Contains("Sample text"));
    }

    [TestMethod]
    [DataRow("document1.html")]
    [DataRow("document2.html")]
    [DataRow("document3.html")]
    public void TestBatchPdfGeneration(string filename)
    {
        // Arrange
        var html = File.ReadAllText(filename);
        var renderer = new ChromePdfRenderer();

        // Act
        var pdf = renderer.RenderHtmlAsPdf(html);

        // Assert
        Assert.IsNotNull(pdf);
        Assert.IsTrue(pdf.PageCount > 0);
    }
}
using Microsoft.VisualStudio.TestTools.UnitTesting;
using IronPdf;
using System.IO;

[TestClass]
public class PdfGenerationTests
{
    [TestMethod]
    public void TestSimpleHtmlToPdf()
    {
        // Arrange
        var renderer = new ChromePdfRenderer();
        var html = "<h1>Test</h1>";

        // Act
        var pdf = renderer.RenderHtmlAsPdf(html);

        // Assert
        Assert.IsNotNull(pdf);
        Assert.IsTrue(pdf.PageCount > 0);
        Assert.IsTrue(pdf.BinaryData.Length > 0);
    }

    [TestMethod]
    public void TestPdfExtraction()
    {
        // Arrange
        var html = "<html><body><p>Sample text for extraction</p></body></html>";
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(html);

        // Act
        var extractedText = pdf.ExtractAllText();

        // Assert
        Assert.IsTrue(extractedText.Contains("Sample text"));
    }

    [TestMethod]
    [DataRow("document1.html")]
    [DataRow("document2.html")]
    [DataRow("document3.html")]
    public void TestBatchPdfGeneration(string filename)
    {
        // Arrange
        var html = File.ReadAllText(filename);
        var renderer = new ChromePdfRenderer();

        // Act
        var pdf = renderer.RenderHtmlAsPdf(html);

        // Assert
        Assert.IsNotNull(pdf);
        Assert.IsTrue(pdf.PageCount > 0);
    }
}
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports IronPdf
Imports System.IO

<TestClass>
Public Class PdfGenerationTests

    <TestMethod>
    Public Sub TestSimpleHtmlToPdf()
        ' Arrange
        Dim renderer As New ChromePdfRenderer()
        Dim html As String = "<h1>Test</h1>"

        ' Act
        Dim pdf = renderer.RenderHtmlAsPdf(html)

        ' Assert
        Assert.IsNotNull(pdf)
        Assert.IsTrue(pdf.PageCount > 0)
        Assert.IsTrue(pdf.BinaryData.Length > 0)
    End Sub

    <TestMethod>
    Public Sub TestPdfExtraction()
        ' Arrange
        Dim html As String = "<html><body><p>Sample text for extraction</p></body></html>"
        Dim renderer As New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf(html)

        ' Act
        Dim extractedText As String = pdf.ExtractAllText()

        ' Assert
        Assert.IsTrue(extractedText.Contains("Sample text"))
    End Sub

    <TestMethod>
    <DataRow("document1.html")>
    <DataRow("document2.html")>
    <DataRow("document3.html")>
    Public Sub TestBatchPdfGeneration(filename As String)
        ' Arrange
        Dim html As String = File.ReadAllText(filename)
        Dim renderer As New ChromePdfRenderer()

        ' Act
        Dim pdf = renderer.RenderHtmlAsPdf(html)

        ' Assert
        Assert.IsNotNull(pdf)
        Assert.IsTrue(pdf.PageCount > 0)
    End Sub

End Class
$vbLabelText   $csharpLabel

使用測試瀏覽器運行這些測試,並使用代碼覆蓋結果窗口分析結果,以保證對文檔處理邏輯的完整測試覆蓋。

整合測試

對於涉及多個Iron Software產品的整合測試:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using IronPdf;
using IronOcr;
using IronBarCode;

[TestClass]
public class DocumentWorkflowTests
{
    [TestMethod]
    public void TestCompleteDocumentWorkflow()
    {
        // Step 1: Generate PDF with barcode
        var renderer = new ChromePdfRenderer();
        var barcode = BarcodeWriter.CreateBarcode("DOC-12345", BarcodeEncoding.QRCode);

        var html = $@"
            <html>
            <body>
                <h1>Document #DOC-12345</h1>
                <img src='{barcode.ToDataUrl()}' />
                <p>This is a test document with a QR code.</p>
            </body>
            </html>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("test-document.pdf");

        // Step 2: Convert PDF to image
        pdf.RasterizeToImageFiles("test-page-*.png");

        // Step 3: Read barcode from image
        var barcodeResults = BarcodeReader.Read("test-page-1.png");

        // Step 4: Verify barcode content
        Assert.IsTrue(barcodeResults.Any());
        Assert.AreEqual("DOC-12345", barcodeResults.First().Value);

        // Step 5: OCR the document
        var ocr = new IronTesseract();
        using (var input = new OcrInput())
        {
            input.AddImage("test-page-1.png");
            var ocrResult = ocr.Read(input);

            Assert.IsTrue(ocrResult.Text.Contains("Document"));
        }
    }
}
using Microsoft.VisualStudio.TestTools.UnitTesting;
using IronPdf;
using IronOcr;
using IronBarCode;

[TestClass]
public class DocumentWorkflowTests
{
    [TestMethod]
    public void TestCompleteDocumentWorkflow()
    {
        // Step 1: Generate PDF with barcode
        var renderer = new ChromePdfRenderer();
        var barcode = BarcodeWriter.CreateBarcode("DOC-12345", BarcodeEncoding.QRCode);

        var html = $@"
            <html>
            <body>
                <h1>Document #DOC-12345</h1>
                <img src='{barcode.ToDataUrl()}' />
                <p>This is a test document with a QR code.</p>
            </body>
            </html>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("test-document.pdf");

        // Step 2: Convert PDF to image
        pdf.RasterizeToImageFiles("test-page-*.png");

        // Step 3: Read barcode from image
        var barcodeResults = BarcodeReader.Read("test-page-1.png");

        // Step 4: Verify barcode content
        Assert.IsTrue(barcodeResults.Any());
        Assert.AreEqual("DOC-12345", barcodeResults.First().Value);

        // Step 5: OCR the document
        var ocr = new IronTesseract();
        using (var input = new OcrInput())
        {
            input.AddImage("test-page-1.png");
            var ocrResult = ocr.Read(input);

            Assert.IsTrue(ocrResult.Text.Contains("Document"));
        }
    }
}
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports IronPdf
Imports IronOcr
Imports IronBarCode

<TestClass>
Public Class DocumentWorkflowTests

    <TestMethod>
    Public Sub TestCompleteDocumentWorkflow()
        ' Step 1: Generate PDF with barcode
        Dim renderer As New ChromePdfRenderer()
        Dim barcode = BarcodeWriter.CreateBarcode("DOC-12345", BarcodeEncoding.QRCode)

        Dim html As String = $"
            <html>
            <body>
                <h1>Document #DOC-12345</h1>
                <img src='{barcode.ToDataUrl()}' />
                <p>This is a test document with a QR code.</p>
            </body>
            </html>"

        Dim pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs("test-document.pdf")

        ' Step 2: Convert PDF to image
        pdf.RasterizeToImageFiles("test-page-*.png")

        ' Step 3: Read barcode from image
        Dim barcodeResults = BarcodeReader.Read("test-page-1.png")

        ' Step 4: Verify barcode content
        Assert.IsTrue(barcodeResults.Any())
        Assert.AreEqual("DOC-12345", barcodeResults.First().Value)

        ' Step 5: OCR the document
        Dim ocr As New IronTesseract()
        Using input As New OcrInput()
            input.AddImage("test-page-1.png")
            Dim ocrResult = ocr.Read(input)

            Assert.IsTrue(ocrResult.Text.Contains("Document"))
        End Using
    End Sub

End Class
$vbLabelText   $csharpLabel

Visual Studio 2026中的自定義參數功能允許在進行整合測試時傳遞不同的測試配置。

在Visual Studio 2026中使用Iron Software的最佳實踐

專案模板與結構

當在Visual Studio 2026中啟動使用Iron Software產品的新專案時:

  1. 使用適當的.NET 10專案模板創建一個專案

    在Visual Studio中創建專案

  2. 安裝所需的Iron Software NuGet套件

    安裝Iron Software NuGet套件

  3. 在應用程式設定中配置授權金鑰

  4. 設置Iron Software服務的相依性注入

  5. 實施適當的錯誤處理和日誌記錄
using Microsoft.Extensions.DependencyInjection;
using IronPdf;
using IronOcr;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // Configure IronPDF
        services.AddSingleton<ChromePdfRenderer>();

        // Configure IronOCR
        services.AddSingleton<IronTesseract>();

        // Add other services
        services.AddLogging();
    }
}
using Microsoft.Extensions.DependencyInjection;
using IronPdf;
using IronOcr;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // Configure IronPDF
        services.AddSingleton<ChromePdfRenderer>();

        // Configure IronOCR
        services.AddSingleton<IronTesseract>();

        // Add other services
        services.AddLogging();
    }
}
Imports Microsoft.Extensions.DependencyInjection
Imports IronPdf
Imports IronOcr

Public Class Startup
    Public Sub ConfigureServices(services As IServiceCollection)
        ' Configure IronPDF
        services.AddSingleton(Of ChromePdfRenderer)()

        ' Configure IronOCR
        services.AddSingleton(Of IronTesseract)()

        ' Add other services
        services.AddLogging()
    End Sub
End Class
$vbLabelText   $csharpLabel

從搜尋中排除文檔

排除文檔

使用Visual Studio 2026的排除文檔功能,防止搜尋生成的PDF或大型文檔文件:

  1. 轉到工具→選項→環境→搜尋

  2. 添加模式如.pdf, .xlsx或output/*/以從搜尋結果中排除這些檔案

  3. 這樣可以提高搜尋性能,並在尋找代碼時減少干擾

持續整合工作流

在部署Iron Software應用程式時利用Visual Studio 2026改進的持續整合工作流:

name: Build and Test

on: [push, pull_request]

jobs:
  build:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup .NET 10
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '10.0.x'

    - name: Restore dependencies
      run: dotnet restore

    - name: Build
      run: dotnet build --configuration Release

    - name: Run unit tests
      run: dotnet test --configuration Release --logger trunit

    - name: Run code coverage
      run: dotnet test --collect:"XPlat Code Coverage"
name: Build and Test

on: [push, pull_request]

jobs:
  build:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup .NET 10
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '10.0.x'

    - name: Restore dependencies
      run: dotnet restore

    - name: Build
      run: dotnet build --configuration Release

    - name: Run unit tests
      run: dotnet test --configuration Release --logger trunit

    - name: Run code coverage
      run: dotnet test --collect:"XPlat Code Coverage"
SHELL

Visual Studio 2026中的GitHub Actions原生支持使得為Iron Software專案設置CI/CD管道變得簡單明瞭。

社群資源與第三方見解

開發者社群一直在積極討論Visual Studio 2026的功能。 根據InfoWorld的報導,Visual Studio 2026被描述為一個"AI原生的智能開發環境","具備性能和用戶體驗的提升,除此之外還具有AI驅動的除錯、剖析等功能"。

根據Techzine Global的另一篇文章指出,"Visual Studio 2026的載入速度比其前身快得多。 對於大型專案,掛起次數減少了50%以上。"這種改進的穩定性對於處理大型檔的文件處理庫尤為有利。

對於感興趣於Visual Studio 2026在Iron Software整合之外的廣泛能力的開發者,這些在Medium和技術新聞網站上的社群討論中,提供了對於真實世界使用經驗與最佳實踐的寶貴見解。

從Visual Studio 2022無縫遷移

2022版本與更新的2026版本的UI對比

Visual Studio 2026的一個主要優勢是其與現有專案的兼容性。 如發布說明所述,Visual Studio 2026兼容於Visual Studio 2022的專案與擴展,無需遷移步驟。 這意味著:

  • 現有的Iron Software專案立即打開而無需修改

  • 超過4000個VS 2022擴展在VS 2026中運行

  • 並置安裝允許逐漸過渡

  • IDE與構建工具分開,防止工具鏈中斷

開發者可以安全地在現有的Visual Studio 2022安裝旁安裝Visual Studio 2026,並評估Iron Software產品在新環境中的表現而無風險。

性能優化提示

內存管理

在處理大檔時,請考慮以下優化策略:

using IronPdf;
using System;

public class OptimizedPdfProcessor
{
    public void ProcessLargeDocument(string htmlPath)
    {
        // Use using statements for proper disposal
        using var renderer = new ChromePdfRenderer();

        // Configure for memory efficiency
        renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;

        // Process in chunks if possible
        var html = File.ReadAllText(htmlPath);
        using var pdf = renderer.RenderHtmlAsPdf(html);

        // Save immediately to free memory
        pdf.SaveAs("output.pdf");

        // PDF is disposed automatically
    }
}
using IronPdf;
using System;

public class OptimizedPdfProcessor
{
    public void ProcessLargeDocument(string htmlPath)
    {
        // Use using statements for proper disposal
        using var renderer = new ChromePdfRenderer();

        // Configure for memory efficiency
        renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;

        // Process in chunks if possible
        var html = File.ReadAllText(htmlPath);
        using var pdf = renderer.RenderHtmlAsPdf(html);

        // Save immediately to free memory
        pdf.SaveAs("output.pdf");

        // PDF is disposed automatically
    }
}
Imports IronPdf
Imports System
Imports System.IO

Public Class OptimizedPdfProcessor
    Public Sub ProcessLargeDocument(htmlPath As String)
        ' Use Using blocks for proper disposal
        Using renderer As New ChromePdfRenderer()

            ' Configure for memory efficiency
            renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print
            renderer.RenderingOptions.PaperSize = PdfPaperSize.A4

            ' Process in chunks if possible
            Dim html As String = File.ReadAllText(htmlPath)
            Using pdf = renderer.RenderHtmlAsPdf(html)

                ' Save immediately to free memory
                pdf.SaveAs("output.pdf")

                ' PDF is disposed automatically
            End Using
        End Using
    End Sub
End Class
$vbLabelText   $csharpLabel

Visual Studio 2026中的淨分配工具可以識別您文件處理代碼中的內存低效率問題。

批量處理

對於處理多個文檔,實施批量處理與適當的資源管理:

using IronPdf;
using System.Collections.Concurrent;
using System.Threading.Tasks;

public class BatchProcessor
{
    public async Task ProcessDocumentsBatch(IEnumerable<string> filePaths)
    {
        var options = new ParallelOptions
        {
            MaxDegreeOfParallelism = Environment.ProcessorCount
        };

        await Parallel.ForEachAsync(filePaths, options, async (path, ct) =>
        {
            using var renderer = new ChromePdfRenderer();
            var html = await File.ReadAllTextAsync(path, ct);
            var pdf = renderer.RenderHtmlAsPdf(html);

            var outputPath = Path.ChangeExtension(path, ".pdf");
            pdf.SaveAs(outputPath);
        });
    }
}
using IronPdf;
using System.Collections.Concurrent;
using System.Threading.Tasks;

public class BatchProcessor
{
    public async Task ProcessDocumentsBatch(IEnumerable<string> filePaths)
    {
        var options = new ParallelOptions
        {
            MaxDegreeOfParallelism = Environment.ProcessorCount
        };

        await Parallel.ForEachAsync(filePaths, options, async (path, ct) =>
        {
            using var renderer = new ChromePdfRenderer();
            var html = await File.ReadAllTextAsync(path, ct);
            var pdf = renderer.RenderHtmlAsPdf(html);

            var outputPath = Path.ChangeExtension(path, ".pdf");
            pdf.SaveAs(outputPath);
        });
    }
}
Imports IronPdf
Imports System.Collections.Concurrent
Imports System.Threading.Tasks

Public Class BatchProcessor
    Public Async Function ProcessDocumentsBatch(filePaths As IEnumerable(Of String)) As Task
        Dim options As New ParallelOptions With {
            .MaxDegreeOfParallelism = Environment.ProcessorCount
        }

        Await Parallel.ForEachAsync(filePaths, options, Async Function(path, ct)
            Using renderer As New ChromePdfRenderer()
                Dim html As String = Await File.ReadAllTextAsync(path, ct)
                Dim pdf = renderer.RenderHtmlAsPdf(html)

                Dim outputPath As String = Path.ChangeExtension(path, ".pdf")
                pdf.SaveAs(outputPath)
            End Using
        End Function)
    End Function
End Class
$vbLabelText   $csharpLabel

結論

Visual Studio 2026代表著.NET開發工具的一大飛躍,其AI驅動的開發特性、改進的性能及與現代引人注目設計原則保持一致的新界面。 最新版本提供了一個出色的環境,用於使用Iron Software全面的文件處理庫套件進行工作。

所有Iron Software產品—包括IronPDFIronOCRIronBarcode,和IronXL—在Visual Studio 2026中運行順暢高效。隨著對.NET 10的全面支持以及與最新C# 14語言功能的無縫兼容,開發者可以自信地使用這些強大的函式庫在Microsoft最新的IDE中構建穩健的文件處理應用程式。

Visual Studio 2026增強的除錯功能、GitHub Copilot整合、改進的代碼覆蓋工具和性能剖析特性,為實施複雜文件工作流創造了一個理想的開發環境。 無論您是從HTML生成PDF從圖片中提取文本與OCR讀取和書寫條形碼,還是操作Excel電子表格,Iron Software產品與Visual Studio 2026的新功能和能力無縫整合。

改進的性能,與更快的解決方案加載、縮短的構建時間和更好的內存管理一起,確保開發者即使在涉及廣泛文件處理的大型專案中也能高效工作。 社群版和專業版現在包含代碼覆蓋分析,普及了幫助確保使用Iron Software程式庫的應用程式質量所需的測試工具。

對於希望利用IDE技術和文件處理能力的最新突破的開發者來說,Visual Studio 2026和Iron Software產品的結合提供了一個強大、現代的開發體驗。 無縫的整合、全面的.NET 10支持和增強的生產力特性使這成為構建需要先進文件處理功能的下一代.NET應用程式的最佳選擇。

隨著Visual Studio 2026和Iron Software持續通過自動月度更新和定期功能增強來發展,開發者可以期待越來越細緻和強大的開發體驗。 這是.NET文件處理的未來,它在Visual Studio 2026中運行良好。


有關Iron Software產品及其功能的更多資訊,請訪問ironsoftware.com,或探索為每個產品提供的綜合文件和教程。