Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 Exception by invoke CreateFile with the ESD file #63

Open
konan54 opened this issue Jul 29, 2021 · 1 comment
Open

Win32 Exception by invoke CreateFile with the ESD file #63

konan54 opened this issue Jul 29, 2021 · 1 comment
Labels

Comments

@konan54
Copy link

konan54 commented Jul 29, 2021

Hi,
I am trying to use Microsoft.dism to apply an ESD format image.
A win32 exception was raised while calling the CreateFile method to deal with the ESD image: "An attempt was made to load a program with an incorrect format."

Issue isolation:
Use the same version of the dism.exe command from the system32 can apply the ESD image successfully.
"dism /apply-image /imagefile:*.esd /index:1 /applydir:c:"

@jeffkl
Copy link
Owner

jeffkl commented Aug 4, 2021

This is usually caused by a mismatch in processor architecture. Managed .NET Framework applications can target "AnyCPU" which will pick the correct architecture at runtime. However, the DISMAPI assemblies are native C++ applications that target x86 or x64 and can cause issues if your process is the wrong architecture.

Try one of the following:

  • Change <Platform> in your project to x64 instead of AnyCPU
  • Set <Prefer32Bit> to true or false

@jeffkl jeffkl added the question label Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants