開啟來自字節的文件時發生錯誤"記憶體分配錯誤"
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 檔案可能會超過此限制,導致發生"分配錯誤"例外狀況。
例外訊息:
IronPdf.Exceptions.IronPdfNativeException: 'Error while opening document from bytes: 'bad allocation'.
解決方案
為解決此問題,請將應用程式設定為 64 位元模式執行。 這使應用程式能夠存取更大的記憶體空間,從而避免發生"記憶體分配錯誤"。 請依照以下步驟設定您的 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 檔案而產生的記憶體分配問題。
準備開始了嗎?
Nuget 下載 19,014,616 | 版本: 2026.5 just released

