從位元組打開文件時出錯 '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文件相關的記憶體分配問題。
準備開始了嗎?
Nuget 下載 19,936,792 | 版本: 2026.7 剛剛發布

