Regsvr32 Hangs

Regsvr32 Hangs

Post by Jonathan W » Mon, 06 Jun 2005 01:03:28


I'm taking over a project, which is basically a huge OCX file that will be
housed on an HTML page.

After some tweaking, I'm able to compile the project under Visual Studio
2003. Everything seems to work except when it goes to register the control:
it just hangs.

I removed the registration step from the build and compiled the OCX. Then I
went to a DOS window and entered:

regsvr32 [myfile].ocx

When I do this, the command line comes right back with no error messages.
All appears normal. However, using Process Explorer, I can see that regsvr32
never terminates. The process remains until I manually terminate it.

I then changed the debugging command for the project to be regsvr32.exe with
my OCX as the argument. I set a breakpoint at the start of DllRegisterServer
and ran the project in debug mode. But my breakpoint is never hit. The
program just hangs there until I manually terminate it.

For some reason, Regsvr32 just hangs. I had an old version lying around,
which was getting loaded but I just uninstalled that entire program.

I don't mind researching this myself but I have no idea where else to look.
Any tips or suggestions would be greatly appreciated.

Jonathan Wood
Available for consulting:

Regsvr32 Hangs

Post by Jonathan W » Mon, 06 Jun 2005 02:34:35


Heh, he's not local so... <g>

You are 100% correct though. I was able to trace it down to a call to
CoCreateInstance that doesn't return. Will do some more research.


Jonathan Wood
Available for consulting:


Regsvr32 Hangs

Post by Joseph M. » Mon, 06 Jun 2005 12:57:41

Does CoCreateInstance perhaps spawn a thread? If it does, it would be fatal in DllMain. Go
to Debug>Threads and see if a thread is hung on a kernel call. This would suggest it is
blocked on the CRITICAL_SECTION which is protecting DllMain. Look at the number of threads
before the CoCreateInstance call, then after it hangs, break into it and see if the number
of threads has increased.

I have tested out code like this by going into the project and setting the Debug option to
run a specific executable (in my case it was IE, but RegSvr32 would be a candidate also).
Just put the command line in the debug window. I then set a breakpoint in my DllMain, and
was able to single-step to what I'd done wrong.

Joseph M. Newcomer [MVP]
MVP Tips:

Regsvr32 Hangs

Post by Alexander » Mon, 06 Jun 2005 13:59:26

I think it's generally prohibited to create objects in DllMain.
CoCreateInstance may cause loading another DLL, which is not allowed in

OTOH, if you need to start a thread from DllMain, you need to call
DisableThreadLibraryCalls for your DLL first.

Regsvr32 Hangs

Post by Jonathan W » Tue, 07 Jun 2005 10:50:04

I'm not sure what CoCreateInstance does here and right now the owner of the
project wants to work out this specific problem.

One thing I can tell you is that the program has been working under Visual
Studio 6, and now we are seeing these errors when compiling under Visual
Studio 2003. So the solution is probably a stupid one but, either way, he's
saving paying me to work on new logic and not fix existing code, which is
fine by me.


Jonathan Wood
Available for consulting:

fatal in DllMain. Go
suggest it is
number of threads
see if the number
Debug option to
candidate also).
my DllMain, and

Regsvr32 Hangs

Post by Rail Jon R » Tue, 28 Jun 2005 09:57:54

Recently I have an issue with my system where I can't install a certain
program (Waves Diamond Bundle).. it'll hang when the DLL's are attempting to
be registered -- I've found that I can't manually register a DLL either..
regsvr32 hangs just as you describe. I'm trying to figure out what's
changed on my system to cause this issue... I was concerned about a
possible virus attack. Have you only seen this since doing any recent XP

Recording Engineer/Software Developer
Rail Jon Rogut Software

Regsvr32 Hangs

Post by Jonathan W » Tue, 28 Jun 2005 13:13:50

was hired as a consulting on this project to write new code and so the
owner decided to try to resolve existing issues with the existing
developers. As near as I can tell, the problem is related to missing or
incorrectly registered components that the project relies on. I believe he
has worked through most of those issue.

I have no indicate that this could be related to any type of virus.

Jonathan Wood
Available for consulting:

"Rail Jon Rogut" < XXXX@XXXXX.COM > wrote in message
news:maIve.12678$ XXXX@XXXXX.COM ...