修復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.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");
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連接錯誤。
準備開始了嗎?
Nuget 下載 20,088,359 | 版本: 2026.7 剛剛發布

