Why is my DLL failing to register?

2019-05-14 16:14发布

I am building a project in VS2005 and several of my DLLs are failing to register. The error message I am getting in Visual Studio is:

Project : error PRJ0019: A tool returned an error code from "Registering ActiveX Control..."

which is nicely vague. When I register the DLL manually through the command line (using regsv32.exe, I get the following error:

LoadLibrary("test.ocx") failed - This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix the problem.

I ran Dependency Walker (depends.exe) on the culprit .ocx file but it isn't showing any obvious problems.

I have also done a re-build but I'm still getting the same problem.

Any suggestions as to how I could determine the cause of this failure to register?

5条回答
三岁会撩人
2楼-- · 2019-05-14 16:46

Probably the easiest way to troubleshoot this whole category of problem is to install Process Monitor from microsoft.com.

Process Montior lets you observe the system calls processes are making, and in this case you will be able to see if some system call is failing. For example, if you are lacking a dependency, then a CreateFile() call will be seen failing with a DLL, OCX, etc. as the filename.

Launch procmon and configure the filter to exclude events other than from regsvr32.exe, reproduce your test case, and then check the log. Look for NAME_NOT_FOUND errors in the return value column.

查看更多
beautiful°
3楼-- · 2019-05-14 16:48

There are several things you can try:

  • try regsvr32 w/ fusion log enabled (fuslogvw.exe - it works for unmanaged dlls as well). This would give you a bit more information than depends on what external dependencies are loaded, where are they loaded from and what errors were hit.
  • copy the .ocx and its dependencies to the root or a first level folder and try registering from there. I don't remember details, but there was an old problem with registering a COM dll from within too deep of a path.
  • run regsvr32 under WinDbg. Set a breakpoint DllMain and see if it does anything funky.
  • If you never break on DllMain in WinDbg, set a breakpoint on module load for your dll and once it's hit, you can either step through LoadLibrary, or just set a generic load library breakpoint and check every dll after that.
查看更多
乱世女痞
4楼-- · 2019-05-14 16:59

Microsoft had recently released a Security Update for ATL (KB971090). It is un update on top of MSVS2005sp1 and it's both compilate-time and runtime compatibility breaker. Check if your building environment has this patch.

References:

查看更多
Animai°情兽
6楼-- · 2019-05-14 17:09

Most probable is because the embedded manifests. You should take a resource explorer application and check your DLLs for the embedded manifests. It might be that one of the dependent DLLs (or your DLL) require some versions of other DLLs which don't exists.

I got this message: "This application has failed to start because the application configuration is incorrect." in case of embedded manifest mistmatches.

查看更多
登录 后发表回答