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

Curtis Chau
Curtis Chau
Updated: 2026年6月10日

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

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

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

解決方案

在連線配置中將IronPdfConnectionType.RemoteServer。 RemoteServer 使用了較新的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");

需求:

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

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

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

閱讀更多

準備開始了嗎?

Nuget Downloads 21,739,885版本:2026.10剛剛發布