hesabixBox/PDFIUM_DLL_FIX_GUIDE.md
2025-10-02 19:12:22 +03:30

46 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# راهنمای حل مشکل PdfiumViewer.dll
## مشکل ۱: DllNotFoundException
خطای `System.DllNotFoundException` با پیام "Unable to load DLL 'pdfium.dll': The specified module could not be found"
## مشکل ۲: BadImageFormatException
خطای `System.BadImageFormatException` با پیام "An attempt was made to load a program with an incorrect format"
## علت مشکلات
1. فایل `pdfium.dll` در مسیر صحیح قرار ندارد
2. تضاد معماری (Architecture) بین برنامه و فایل DLL
## راه حل‌های کامل
### مرحله ۱: حل مشکل DllNotFoundException
```powershell
# کپی به پوشه Release
Copy-Item "bin\Release\packages\PdfiumViewer.Native.x86_64.no_v8-no_xfa.2018.4.8.256\content\x64\pdfium.dll" "bin\Release\pdfium.dll" -Force
# کپی به پوشه Debug
Copy-Item "bin\Release\packages\PdfiumViewer.Native.x86_64.no_v8-no_xfa.2018.4.8.256\content\x64\pdfium.dll" "bin\Debug\pdfium.dll" -Force
```
### مرحله ۲: حل مشکل BadImageFormatException
فایل `HesabixBox.vbproj` بروزرسانی شده تا:
- `PlatformTarget` از `AnyCPU` به `x64` تغییر یافته
- این تضمین می‌کند که برنامه با معماری 64-bit کامپایل شود
### مرحله ۳: استفاده از اسکریپت خودکار
فایل `copy_pdfium_dll.ps1` را اجرا کنید:
```powershell
powershell -ExecutionPolicy Bypass -File copy_pdfium_dll.ps1
```
## بررسی حل مشکل
پس از اجرای راه حل، موارد زیر باید درست باشند:
- فایل `pdfium.dll` در `bin\Release\pdfium.dll` موجود باشد
- فایل `pdfium.dll` در `bin\Debug\pdfium.dll` موجود باشد
- پروژه با `PlatformTarget=x64` کامپایل شود
## نکات مهم
- این مشکلات معمولاً بعد از build مجدد پروژه رخ می‌دهد
- اگر مشکل ادامه داشت، مطمئن شوید که فایل‌های کپی شده حذف نشده‌اند
- برای پروژه‌های جدید، از تنظیمات بروزرسانی شده در `HesabixBox.vbproj` استفاده کنید
- برنامه حالا فقط روی سیستم‌های 64-bit اجرا خواهد شد