LoadImageW fails with error code 0x06 (ERROR_INVALID_HANDLE) in Azure App Service

Madalin 1 Reputation point
2022-01-28T14:35:17.767+00:00

Hello,

I've just published my ASP.NET Framework 4.6.2 Web application (x64) to Azure App Service. I also have some additional native DLLs and bitmap images, all manually copied to the "bin" root folder.

The problem is that LoadImageW returns "invalid handle" error code (dw is 0x06):

HBITMAP hBMP = (HBITMAP)LoadImageW(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (hBMP == NULL) {
    DWORD dw = GetLastError();

But if I just do this, it works, "result" is 0:

FILE* pFile;
int result = _wfopen_s(&pFile, file, L"wb");

So the path is ok, the file can be accessed, it is only LoadImage which doesn't work, and it happens only in Azure, locally everything is ok.

I would very much appreciate any help, any idea.

Thank you!

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,022 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Madalin 1 Reputation point
    2022-01-28T19:29:13.73+00:00

    Apparently it has to do with the Azure Web App sandbox restrictions.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.