修復macOS ARM上的IronPdfEngine Docker連線失敗

This article was translated from English: Does it need improvement?
Translated
View the article in English

當在macOS ARM裝置(Apple Silicon)上透過Docker將.NET應用程式連接到IronPdfEngine時,應用程式拋出異常:

Unhandled exception. System.IO.FileNotFoundException: Error loading native library.
Not found in any of the possible locations

IronPdfConnectionType.Docker 使用了較舊的gRPC實現,不支持ARM架構。 在macOS ARM(Apple Silicon)上,即使強制Docker映像以--platform linux/amd64運行,.NET客戶端也無法載入所需的原生gRPC二進位。 Windows和Linux x64平台不受影響。

解決方案

在連線配置中將IronPdfConnectionType.RemoteServerRemoteServer 使用了較新的gRPC實現,支持ARM:

using IronPdf;

var config = new IronPdfConnectionConfiguration
{
    ConnectionType = IronPdfConnectionType.RemoteServer,
    Host = "http://127.0.0.1",
    Port = 33350
};

IronPdf.Installation.ConnectToIronPdfHost(config);

IronPdf.License.LicenseKey = Environment.GetEnvironmentVariable("IRONPDF_LICENSE_KEY");

var renderer = new ChromePdfRenderer();
var pdf = await renderer.RenderHtmlAsPdfAsync("<h1>Hello from IronPdfEngine</h1>");
pdf.SaveAs("output.pdf");
using IronPdf;

var config = new IronPdfConnectionConfiguration
{
    ConnectionType = IronPdfConnectionType.RemoteServer,
    Host = "http://127.0.0.1",
    Port = 33350
};

IronPdf.Installation.ConnectToIronPdfHost(config);

IronPdf.License.LicenseKey = Environment.GetEnvironmentVariable("IRONPDF_LICENSE_KEY");

var renderer = new ChromePdfRenderer();
var pdf = await renderer.RenderHtmlAsPdfAsync("<h1>Hello from IronPdfEngine</h1>");
pdf.SaveAs("output.pdf");
Imports IronPdf

Dim config As New IronPdfConnectionConfiguration With {
    .ConnectionType = IronPdfConnectionType.RemoteServer,
    .Host = "http://127.0.0.1",
    .Port = 33350
}

IronPdf.Installation.ConnectToIronPdfHost(config)

IronPdf.License.LicenseKey = Environment.GetEnvironmentVariable("IRONPDF_LICENSE_KEY")

Dim renderer As New ChromePdfRenderer()
Dim pdf = Await renderer.RenderHtmlAsPdfAsync("<h1>Hello from IronPdfEngine</h1>")
pdf.SaveAs("output.pdf")
$vbLabelText   $csharpLabel

需求:

  • 在呼叫ConnectToIronPdfHost之前,IronPdfEngine Docker容器必須正在運行,並可在指定的主持人和端口上存取。
  • 使用https://; 在沒有有效SSL證書的情況下使用https://會導致gRPC通道中的幀損毀錯誤。

另請參閱:在Docker中排除Vulkan/ANGLE初始化錯誤修復Azure Containers中的gRPC連接錯誤

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

準備開始了嗎?
Nuget 下載 20,088,359 | 版本: 2026.7 剛剛發布
Still Scrolling Icon

還在捲動嗎?

想快速獲得證明嗎? PM > Install-Package IronPdf
執行範例 看您的HTML變成PDF。