從位元組打開文件時出錯 'bad allocation'

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

處理大型PDF文件對某些企業來說至關重要。

當使用IronPDF載入現有的PDF文件時,IronPDF會分配部分記憶體來儲存已載入的PDF。 運行在32位上的應用程式每個進程的記憶體限制為2 GB。 載入大於500 MB的PDF文件可能會超過此限制,導致'b裝配錯誤'异常。

异常資訊:

IronPdf.Exceptions.IronPdfNativeException: 'Error while opening document from bytes: 'bad allocation'.

解決方案

為了解決此問題,請將應用程式設置為在64位上運行。 這允許應用程式存取更大的記憶體空間,避免'b裝配錯誤'。 請按照以下步驟配置您的Visual Studio項目,以定位一個64位的平台:

// Open your project in Visual Studio
// In the Solution Explorer, right-click on your project and select 'Properties'

// Navigate to the 'Build' tab

// Select 'x64' from the 'Platform target' dropdown
<PropertyGroup>
  <PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

// Save your changes and rebuild the project
// Open your project in Visual Studio
// In the Solution Explorer, right-click on your project and select 'Properties'

// Navigate to the 'Build' tab

// Select 'x64' from the 'Platform target' dropdown
<PropertyGroup>
  <PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

// Save your changes and rebuild the project
' Open your project in Visual Studio
' In the Solution Explorer, right-click on your project and select 'Properties'

' Navigate to the 'Build' tab

' Select 'x64' from the 'Platform target' dropdown
(Of PropertyGroup) (Of PlatformTarget) x64</PlatformTarget> </PropertyGroup>

' Save your changes and rebuild the project
$vbLabelText   $csharpLabel

通過將平台目標設置為x64,應用程式可以利用64位系統的擴展記憶體容量,從而防止與大型PDF文件相關的記憶體分配問題。

Curtis Chau
技術作家

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

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

準備開始了嗎?
Nuget 下載 19,936,792 | 版本: 2026.7 剛剛發布
Still Scrolling Icon

還在捲動嗎?

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