IRONSOFTWAREHOME
VIDEOLAR

DevExpress Barkod'dan IronBarcode'a Geçiş

Curtis Chau
Curtis Chau
Updated: 20 Haziran 2026

Grid, grafik, zamanlayıcı veya pivot kontrolleri için DevExpress kullanıyorsanız, bunları tutun. Bu geçiş, BarCodeControl'i başsız çalışabilen, UI bağlamı dışında dağıtılabilen ve barkodları okuyabilen bir kütüphane ile değiştirmek hakkındadır. WinForms veya Blazor uygulamanız için güvendiğiniz DevExpress UI kontrolleri bu geçişten etkilenmez. Yalnızca barkodla ilgili kod değişir.

Bu geçişi gerektiren tipik senaryo üç şeyden biridir: bir okuma gerekliliği ortaya çıkar ve DevExpress bunu karşılayamaz; yeni bir servis, WinForms derlemelerinin olmadığı bir ASP.NET Core veya bulut fonksiyonunda barkod üretimi gerektirir; veya süit yenilemesi yaklaşır ve yalnızca barkod çıktısı için tam bir UI araç seti kullanmanın maliyet-başına-özellik matematiği artık mantıklı gelmez.

Adım 1: IronBarcode'u Kurun

dotnet add package BarCode

Aynı projede başka DevExpress kontrolleri bulunduruyorsanız, DevExpress NuGet paketlerini yerinde bırakın. Yalnızca kaynak dosyalarınızdaki barkodla ilgili kod değişir. DevExpress'ün belirli bir projede görünmesinin tek nedeni barkod üretimiyse ve orada başka DX kontrolleri kullanmıyorsanız, geçişten sonra DevExpress paketlerini o projeden kaldırabilirsiniz:

# Only remove DevExpress packages if no other DX controls are used in this project
dotnet remove package DevExpress.Win.Navigation
SHELL

Adım 2: Lisans Başlatma Ekle

Uygulama başlatıldığında IronBarcode lisans aktivasyonunu bir kez ekleyin — Program.cs, App.xaml.cs veya ana bilgisayarınızı inşa edicinizde:

// In Program.cs (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

Ağ çağrısı yok. Kontrol edilecek hata kodu yok. Yerel doğrulama.

Adım 3: Barkoda Özgü Kodu Değiştirin

Kod tabanınızda DevExpress barkod tiplerini arayın. Diğer her şey kalır:

# Find barcode-related DevExpress usage — ignore grid, chart, and other DX components
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator\|DevExpress.XtraPrinting.BarCode" --include="*.cs" .
grep -r "barCode\.Module\|DrawToBitmap\|BarCode\.Symbology" --include="*.cs" .
SHELL

Bu aramanın sonuçları tam olarak neyi değiştireceğinizdir. Başka bir şey yok.

Kod Göç Örnekleri

Code 128 Üretimi

Bu, en yaygın geçiştir. BarCodeControl ile Code128Generator sembolojisi bir tek BarcodeWriter.CreateBarcode çağrısına dönüşür.

Öncesi — DevExpress WinForms kontrolü:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateCode128(string data, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new Code128Generator();
    symbology.CharacterSet = Code128CharacterSet.CharsetAuto;
    barCode.Symbology = symbology;
    barCode.Text = data;
    barCode.Module = 0.02f;
    barCode.ShowText = true;

    barCode.Width = 400;
    barCode.Height = 100;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}

Sonrası — IronBarcode:

// NuGet: dotnet add package BarCode
using IronBarCode;

public void GenerateCode128(string data, string outputPath)
{
    BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .SaveAsPng(outputPath);
}

barCode.Module = 0.02f döküman-birimi boyutlandırması kalktı. .ResizeTo(400, 100), pikselleri doğrudan alır. Manuel Bitmap tahsisi ve DrawToBitmap çağrısı, boyutlandırmayı otomatik olarak halleden .SaveAsPng() ile değiştirildi.

QR Kod Oluşturma

Öncesi — Hata düzeltmeli DevExpress QR:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;

public void GenerateQrCode(string url, string outputPath)
{
    var barCode = new BarCodeControl();
    var symbology = new QRCodeGenerator();
    symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
    symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric;
    barCode.Symbology = symbology;
    barCode.Text = url;

    barCode.Width = 500;
    barCode.Height = 500;
    var bitmap = new Bitmap(barCode.Width, barCode.Height);
    barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
    bitmap.Save(outputPath, ImageFormat.Png);
    bitmap.Dispose();
}

Sonrası — IronBarcode:

using IronBarCode;

public void GenerateQrCode(string url, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .SaveAsPng(outputPath);
}

QRCodeErrorCorrectionLevel.H, QRCodeWriter.QrErrorCorrectionLevel.Highest'a eşlenir. CompactionMode.AlphaNumeric ayarı, içeriğe göre IronBarcode tarafından otomatik olarak ele alınır.

Marka logosu ile QR kod (net yeni yetenek — DevExpress ile mümkün değil):

using IronBarCode;

public void GenerateBrandedQrCode(string url, string logoPath, string outputPath)
{
    QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .AddBrandLogo(logoPath)
        .SaveAsPng(outputPath);
}

Data Matrix Üretimi

Önce — DevExpress:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
var symbology = new DataMatrixGenerator();
symbology.MatrixSize = DataMatrixSize.Matrix26x26;
barCode.Symbology = symbology;
barCode.Text = "PART-7734-X";
// ... DrawToBitmap pattern

Sonrası — IronBarcode:

using IronBarCode;

BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix)
    .ResizeTo(260, 260)
    .SaveAsPng("datamatrix.png");

PDF417 Üretimi

Önce — DevExpress:

using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

var barCode = new BarCodeControl();
barCode.Symbology = new PDF417Generator();
barCode.Text = "SHIPMENT-DATA-2026";
// ... DrawToBitmap pattern

Sonrası — IronBarcode:

using IronBarCode;

BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417)
    .ResizeTo(400, 150)
    .SaveAsPng("pdf417.png");

Okuma Ekleyin (Net Yeni Yetenek)

DevExpress bir okuma API'si sağlamaz. Bir okuma gereksinimi geldiyse, IronBarcode burada kendini hemen öder:

using IronBarCode;

// Read from an image file
var results = BarcodeReader.Read("uploaded-label.png");
foreach (var result in results)
{
    Console.WriteLine($"Found {result.Format}: {result.Value}");
}

// Read with options for better accuracy on difficult images
var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    MaxParallelThreads = 4
};
var detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options);

ASP.NET Core Barkod Uç Noktası

Bu, WinForms çözümleri olmadan BarCodeControl ile mümkün değildi. IronBarcode bunu doğal olarak destekler:

using IronBarCode;

// In Program.cs or a controller
app.MapGet("/label/{sku}", (string sku) =>
{
    var pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png", $"{sku}.png");
});

app.MapGet("/qr/{data}", (string data) =>
{
    var pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest)
        .ToPngBinaryData();

    return Results.File(pngBytes, "image/png");
});

PDF'lerden Barkod Okuma

IronBarcode, PDF dosyalarından yerel olarak okur. PdfiumViewer yok, render döngüsü yok, ek paketler yok:

using IronBarCode;

// Read all barcodes from all pages of a PDF
var results = BarcodeReader.Read("shipping-manifest.pdf");
foreach (var result in results)
{
    Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}");
}

Yaygın Geçiş Sorunları

barCode.Module Belge Birimlerini Kullanır, Pikseli Değil

barCode.Module, belgedeki en dar çubuğun genişliğini kontrol eder (render DPI bağlamına bağlıdır). Bu bir piksel sayısı değildir. Geçiş sırasında, modül değerini piksellere dönüştürmeye çalışmayın - bunun yerine, hangi piksel boyutlarını istediğinize karar verin ve doğrudan .ResizeTo(width, height) kullanın.

// Before: barCode.Module = 0.02f  — document units, indirect sizing
// After:
.ResizeTo(400, 100)  // explicit pixel dimensions

DrawToBitmap, Önceden Ayrılmış Bitmap Gerektirir

Eski model, belirli bir boyuttaki bir Bitmap tahsis ederdi, ardından bunu render etmek için DrawToBitmap çağrılırdı. IronBarcode'un .SaveAsPng() bunu dahili olarak halleder. Önceden herhangi bir şey tahsis etmezsiniz.

// Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(path, ImageFormat.Png);
bitmap.Dispose();

// After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng(path);

WinForms Veri Bağlama

BarCodeControl bir WinForms tasarımcısında bir veri kaynağına bağlıysa, IronBarcode eşdeğeri, değeri modelinizden açıkça okumak ve BarcodeWriter.CreateBarcode 'a geçmektir. IronBarcode, WinForms veri bağlamasında yer almaz — bu bir programatik API, bir UI kontrolü değil. Oluşturulan barkodu bir formda göstermeniz gerekiyorsa, görüntü baytlarını oluşturun ve bir PictureBox üzerinde ayarlayın:

using IronBarCode;

// Generate and display in a WinForms PictureBox
private void UpdateBarcodeDisplay(string value)
{
    var bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128)
        .ResizeTo(400, 100)
        .ToPngBinaryData();

    using var ms = new System.IO.MemoryStream(bytes);
    pictureBox1.Image = System.Drawing.Image.FromStream(ms);
}

Ad Alanı Değiştirme

Kaldırılacak eski ithalatlar:

// Remove these
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;

Eklenecek yeni ithalat:

// Add this
using IronBarCode;

API Eşleme Başvurusu

DevExpress BarkodIronBarcode Eşdeğeri
new BarCodeControl()Statik — örnek yok
new Code128Generator() + barCode.Symbology = symbologyBarcodeEncoding.Code128 parametresi
new QRCodeGenerator() + QRCodeErrorCorrectionLevel.HQRCodeWriter.CreateQrCode(data, size, QRCodeWriter.QrErrorCorrectionLevel.Highest)
new DataMatrixGenerator() + DataMatrixSize.Matrix26x26BarcodeWriter.CreateBarcode(data, BarcodeEncoding.DataMatrix)
new PDF417Generator()BarcodeWriter.CreateBarcode(data, BarcodeEncoding.PDF417)
new AztecCodeGenerator()BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Aztec)
barCode.Text = valueİlk argüman CreateBarcode veya CreateQrCode
barCode.Module = 0.02f.ResizeTo(width, height) piksellerde
barCode.ShowText = true.AddBarcodeText()
DrawToBitmap(bitmap, rect).SaveAsPng(path)
new Bitmap(w, h) + manuel imhaGerekli değil
Bitmap → MemoryStream → HTTP.ToPngBinaryData()
Okuma API'si yokBarcodeReader.Read(path)
using DevExpress.XtraEditors + using DevExpress.XtraPrinting.BarCodeusing IronBarCode

Geçiş Kontrol Listesi

Güncellenmesi gereken tüm dosyaları bulmak için bu grep desenini kullanın:

grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator" --include="*.cs" .
grep -r "barCode\.Module\|barCode\.Symbology\|DrawToBitmap\|DevExpress\.XtraPrinting\.BarCode" --include="*.cs" .
SHELL

Her bir eşleşme üzerinde çalışın:

  • using DevExpress.XtraEditors; ve using DevExpress.XtraPrinting.BarCode;'i using IronBarCode; ile değiştirin
  • new BarCodeControl() + semboloji kurulumunu BarcodeWriter.CreateBarcode(data, BarcodeEncoding.X) ile değiştirin
  • new QRCodeGenerator() + semboloji kurulumunu QRCodeWriter.CreateQrCode(data, size, errorLevel) ile değiştirin
  • barCode.Module = X'i .ResizeTo(width, height) ile değiştirin
  • DrawToBitmap + bitmap.Save modelini .SaveAsPng(path) ile değiştirin
  • Bitmap-to-MemoryStream modelini .ToPngBinaryData() ile değiştirin
  • Uygulama başlatıldığında IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY" ekleyin
  • Okuma becerisinin gerektiği her yerde BarcodeReader.Read() çağrıları ekleyin

Bir proje, yalnızca barkod kontrolleri için DevExpress kullanıyorsa ve başka DX bileşenleri kullanmıyorsa, tüm barkod referansları değiştirildikten sonra DevExpress NuGet paketlerini kaldırın. Proje, DevExpress grid, grafik veya diğer UI kontrollerini kullanıyorsa, bu paketleri yerinde bırakın — bu geçiş yalnızca barkod kodunu etkiler.

Curtis Chau
Teknik Yazar

Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapılandırılmış, görsel olarak çekici kılavuzlar oluşturmayı seviyor.

...
Daha Fazla Oku

İlgili Makaleler

Key in blue circle

Ücretsiz 30 günlük Deneme Anahtarınızı anında edinin.

Your trial license will be sent to your email address

Herhangi bir sınırlama yoktur. %100 erişim. Kredi kartı gerekmez.

bullet_checkedKredi kartı veya hesap oluşturma gerektirmezHerhangi bir sınırlama yoktur. %100 erişim. Kredi kartı gerekmez.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Ücretsiz Canlı Demo rezervasyonu yapın
Booking Badge

Dünya Çapında Milyonlarca Mühendisin Güvendiği

Iron Software müşteri logoları
Bağımsız Danışmanlık Alın
Aşağıdaki formu doldurun veya sales@ironsoftware.com adresine e-posta gönderin
Bilgileriniz daima gizli kalacaktır.
Dünya Çapında Milyonlarca Mühendisin Güvendiği
Iron Software müşteri logoları
Ücretsiz 30 Günlük Deneme Anahtarınızı anında alın.
Kredi kartı veya hesap oluşturma gerektirmez