IronBarcode 操作指南 创建 MSI 安装程序 Creating a MSI Installer with IronBarCode Curtis Chau 已更新:九月 23, 2025 Download IronBarcode NuGet 下载 DLL 下载 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English MSI(Microsoft Installer)是一个Windows安装包,便于管理软件安装、更新和移除。 使用MSI提供了一个标准化的应用程序安装方法,这对企业级部署尤其有利。 IronBarCode提供了工具,可以无缝地与您的现有应用程序集成,并将其转换为MSI以便于分发。 它确保在各种环境下的可靠安装,并允许开发人员选择要包含或排除的组件。 本教程将简要演示如何从示例条码应用程序创建一个MSI文件。 快速入门:一键生成和读取MSI条形码 使用IronBarCode的简单API在最少的设置下创建和读取MSI条码。下面的代码片段显示了如何轻松地写出一个MSI条码图像,然后读取它——只需几行代码。 Get started making PDFs with NuGet now: Install IronBarcode with NuGet Package Manager PM > Install-Package BarCode Copy and run this code snippet. var msiImg = IronBarCode.BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.MSI).SaveAsImage("msi.png"); var results = IronBarCode.BarcodeReader.Read("msi.png", new BarcodeReaderOptions { ExpectBarcodeTypes = BarcodeEncoding.MSI }); Deploy to test on your live environment Start using IronBarcode in your project today with a free trial Free 30 day Trial class="hsg-featured-snippet"> 最小工作流程(5步) 下载C#库以创建MSI安装程序 从工具箱添加一个新按钮 编辑按钮的代码以调用条码读取 添加并配置安装项目 下载示例项目以快速开始 今天在您的项目中使用 IronBarcode,免费试用。 第一步: 免费开始 先决条件 在我们开始项目之前,请下载 Microsoft Visual Studio Installer Projects 扩展 以使MSI构建工作。 创建MSI安装程序 我们将使用Windows窗体应用程序(.NET框架)项目演示此示例的功能。 添加按钮 导航到工具箱 搜索按钮 将按钮通过拖放添加到窗体中。 编辑按钮代码 双击按钮组件以访问窗体的C#代码。 以下是窗体组件的逻辑,它输入条码并尝试扫描。 该代码仅扫描图像,不适用于PDF。 对于PDF文档,请使用ReadPdf方法。 using IronBarCode; using IronSoftware.Drawing; using System; using System.Drawing; using System.Windows.Forms; namespace MsiInstallerSample { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All; IronSoftware.Logger.LogFilePath = "Default.log"; IronBarCode.License.LicenseKey = "IRONBARCODE-MYLICENSE-KEY-1EF01"; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "Image files (All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { // Load the selected image using (Bitmap bmp = new Bitmap(openFileDialog.FileName)) { // Process the image AnyBitmap anyBitmap = AnyBitmap.FromBitmap(bmp); // Configure barcode reader options (customize as needed) var option = new BarcodeReaderOptions { Speed = ReadingSpeed.Detailed, ExpectMultipleBarcodes = true, ScanMode = BarcodeScanMode.Auto, }; BarcodeResults result = IronBarCode.BarcodeReader.Read(anyBitmap, option); if (result.Count > 0) { string output = string.Empty; foreach(var barcode in result) { Console.WriteLine($"Barcode Found: {barcode.Text}"); output += barcode.Text + "\n"; } MessageBox.Show($"Detected Barcodes: \n{output}"); } else { MessageBox.Show("No Barcode found."); } } } catch (Exception ex) { MessageBox.Show($"{ex.Message}"); } } } } } } using IronBarCode; using IronSoftware.Drawing; using System; using System.Drawing; using System.Windows.Forms; namespace MsiInstallerSample { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All; IronSoftware.Logger.LogFilePath = "Default.log"; IronBarCode.License.LicenseKey = "IRONBARCODE-MYLICENSE-KEY-1EF01"; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "Image files (All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { // Load the selected image using (Bitmap bmp = new Bitmap(openFileDialog.FileName)) { // Process the image AnyBitmap anyBitmap = AnyBitmap.FromBitmap(bmp); // Configure barcode reader options (customize as needed) var option = new BarcodeReaderOptions { Speed = ReadingSpeed.Detailed, ExpectMultipleBarcodes = true, ScanMode = BarcodeScanMode.Auto, }; BarcodeResults result = IronBarCode.BarcodeReader.Read(anyBitmap, option); if (result.Count > 0) { string output = string.Empty; foreach(var barcode in result) { Console.WriteLine($"Barcode Found: {barcode.Text}"); output += barcode.Text + "\n"; } MessageBox.Show($"Detected Barcodes: \n{output}"); } else { MessageBox.Show("No Barcode found."); } } } catch (Exception ex) { MessageBox.Show($"{ex.Message}"); } } } } } } IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel 添加安装项目 在设置好窗体及其控制逻辑后,我们需要在现有解决方案中添加一个安装项目以创建MSI安装程序。 安装项目允许我们为刚刚创建的应用程序构建一个安装程序。 右键点击解决方案,然后转到添加 > 新项目... 对于MSI安装程序,再次以发布模式构建MsiInstallerSample项目。 右键点击安装项目,然后转到添加 > 项目输出... 为了确保MSI安装程序的顺利运行,您必须在安装项目中包括以下三个文件:onnxruntime.dll、IronBarcodeInterop.dll和ReaderInterop.dll。 这些文件在以发布模式构建项目时生成: onnxruntime.dll:位于MsiInstallerSample\MsiInstallerSample\bin\Release IronBarcodeInterop.dll:位于MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\native ReaderInterop.dll:位于MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\native 如果任何这些文件丢失,您可能会遇到以下异常信息,如该故障排除文章中所述:创建MSI安装程序时缺少DLL 最后,构建安装项目。 安装程序将位于:MsiInstallerSample\SetupProject\Release 运行并测试安装程序 我们用MSI文件安装应用程序以确保一切顺利进行。 下载MSI安装程序示例项目 您可以下载本指南的完整代码。它以压缩文件的形式提供,您可以在Visual Studio中作为WinFormApp项目打开。 下载WinForm MSI应用程序项目 常见问题解答 什么是 IronBarCode? IronBarCode 是一个库,允许开发人员在 .NET 应用程序中读取、写入和生成条码。它支持多种条码格式,设计易于集成。 如何创建带有 IronBarCode 的 MSI 安装程序? 要创建带有 IronBarCode 的 MSI 安装程序,您需要将 IronBarCode 库集成到您的应用程序中,并使用 Visual Studio Installer Projects 等工具遵循标准程序来创建 MSI 安装程序。 在 MSI 安装程序中使用 IronBarCode 有什么好处? 将 IronBarCode 集成到 MSI 安装程序中简化了需要条码功能的应用程序的部署过程,确保所有必要的组件均正确安装在最终用户的系统上。 IronBarCode 支持哪些条码格式? IronBarCode 支持多种条码格式,包括 QR 码、UPC、EAN、Code 39、Code 128 等,使其对各种应用需求而言具有灵活性。 是否可以使用 IronBarCode 自定义条码外观? 是的,IronBarCode 允许自定义条码外观,包括颜色、尺寸和文本注释,以适应您的应用程序特定设计要求。 集成 IronBarCode 到 MSI 安装程序是否需要特定工具? 您可以使用常见的开发工具,如 Visual Studio,将 IronBarCode 集成到您的应用程序中并创建 MSI 安装程序。 IronBarCode 库兼容 .NET,使其对使用此框架的开发人员可访问。 IronBarCode 可以读取和写入 2D 条码吗? 是的,IronBarCode 可以读取和写入 1D 和 2D 条码,包括 QR 码和 Data Matrix 等,提供全面的条码功能。 使用 IronBarCode 的系统要求是什么? IronBarCode 需要 .NET 框架环境才能运行。它兼容 .NET Core、.NET 5/6 及早期版本,确保跨不同项目的广泛兼容性。 如何开始使用 IronBarCode? 要开始使用 IronBarCode,您可以从 Iron Software 网站上下载该库,查看文档,并根据提供的示例和指导将其集成到您的 .NET 项目中。 IronBarCode 用户是否有技术支持? 是的,Iron Software 为 IronBarCode 用户提供技术支持,包括文档、教程和直接支持选项,以协助解决集成和使用问题。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 准备开始了吗? Nuget 下载 1,935,276 | 版本: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:1,935,276 查看许可证