修复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.Docker。 RemoteServer 使用与ARM兼容的较新的gRPC实现:

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容器中的gRPC连接错误。

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

阅读更多

准备开始了吗?

Nuget Downloads 21,739,885版本:2026.10刚刚发布