We help IT Professionals succeed at work.

GDIPlus calls crash on a PC

tullhead
tullhead asked
on
Medium Priority
59 Views
Last Modified: 2020-03-10
Have an application in VC++ VS2017 that runs fine on hundreds of PCs.   I'm now trying to run this code on an AWS windows server and my code crashes when it attempts to call entry points in gdiplus.dll

I can see that gdiplus.dll exists on the server in windows/system32.   If I try a regsvr32 on it, it fails.

Also the version of gdiplus.dll on this server is slightly older than the one I use elsewhere.

What is recommended course of action?
Comment
Watch Question

John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Well some points here...
1st if the version is slighty older then this can be the issue....even a minor deviation could break "hell" (i have encountered some really nasty crashes with similar cases). Make absolutely certain that your versions match 100% ...you need the exact version.
Also take note about the bitness of this .dll ...it could be 32bit or 64bit ...99% your application is 32bit your application is 32bit so you have to open a cmd prompt with admin rights...go to C:\Windows\SYSWOW64 folder...
regsvr32 /u gdiplus.dll
to unregister the current instance
rename it
copy the correct version to SYSWOW64 folder
register it
regsvr32  gdiplus.dll
( Crucial part...there are 2 versions of regsvr32 ...one for 64bit .dlls located in C:\Windows\System32 and one for 32 bit .dlls located in C:\Windows\SYSWOW64 use the one that matches your .dll bitness or else it will fail) 

Author

Commented:
OK, this is helpful information -- will try some things when I get into work.  It happens that this application is 64-bit, but all my previous work has been 32-bit, so I am not 'tuned up' to thinking about the bitness.  So, perhaps being careful about that will yield something.  Thank you.  One question: if I want to place the matching version of gdiplus.dll then must I also worry about sub-dlls that it may use -- like gdi.dll -- so pehaps I have to place a whole set of dlls of the proper version numbers -- and how to I discover what they all are?  DLL hell, I guess.
John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I am not sure if i can help you on that...my initial move would be to replace the gdiplus.dll and see if it works.
If not there is a tool called Dependency Walker that is supposed to do exactly this

Author

Commented:
Just another dumb question (while I wait for permission to fiddle the server) -- is GdiPlus.dll an OCX ?   I guess it must be, or I wouldn't have to do the regsvr32 thing, right?   I had thought it was a plain dll.

Author

Commented:
Maybe I should go another way on this.  I don't seem to have permissions to regsvr2 dlls on the target machine -- so maybe I should build a version of my app with the older version of GdiPlus.  But how to do this?

Here is a restatement of my problem....

My app uses gdiplus.dll and is built with Windows SDK 10.0.18362.0 corresponding to Windows 10 version 1903. Works fine on that OS version.

When I try to run it on Windows 10 version 1809 it crashes on calls to gdiplus.

Without having a windows 10 version 1809 computer here, can I build it with the older gdiplus so that it will run on OS 1809? And if the answer is Yes, it would seem that I need to get the older gdiplus.lib and *.h -- but those don't see to be available...?
Commented:
OK, my bad.  Finally figured it out.  To use GDI+ you have to call an Initialize function.  I was doing that in a larger app, but had recently extracted a smaller app from it, but forgot to take the initialize stuff.  Was confusing because it seems that if I had run the larger app on the same PC, then the smaller app (without the initialize) would work.  But if truly on its own, the smaller app would fail.

Author

Commented:
Thank you!