简体   繁体   中英

VS 2003 fails to regsvr32 during post build. No issues from command prompt

Regsvr32 fails as a post build event for a DLL project.

Post Build Event: regsvr32 /s /c "$(TargetPath)" (also tried without quotes).

Removing the /s results in the error message LoadLibrary("...") failed - The specified module could not be found.

If I run regsvr32 from command prompt the result is successful. If I copy and run or even directly run the "BAT000019.bat" file I get the resulting message "DllRegisterServer in...dll succeeded." I have loaded the DLL in Dependency Walker and found no issues. This has worked in the past, but suddenly started having issues. I have about 50 projects which have the same post build event, only about 3 have this issue. The DLL file does exist at the time the bat file is generated (maybe it's in use???).

I don't see any issues with the generated bat file:

@echo off
regsvr32 /c "C:\ ... .dll"
if error level 1 goto VCReportError
goto VCEnd
:VCReportError
echo Project : error PRJ0019: A tool returned an error code from "Performing registration"
exit 1
:VCEnd

Other information: OS: Windows XP SP3. IDE: VS 2003 Pro (up to date). Language: C++

I could just remove the post build event, but would rather keep it for some of our newer program debuggers.

Anyone have any thoughts on how to fix this?

Other things I've tried: Relative path to DLL in post build event. (fails) Absolute path to DLL in post build event. (fails) With an without quotes (nothing in the absolute path contains a space). (fails)

I think your project isn't made by just one DLL, maybe the DLL you're building depends on other libraries (check with DependencyWalker andverify if LoadLibrary / GetProcAddress too) but they're not there for the post-build event of the dll.

If you run from the command prompt in the output directory there is everything your dll needs so it can be registered.

For what I know you can't set a post-build event for the solution so please check your project dependencies/build order). I assume you're not trying to register a dll alone in its output directory without its dependencies (the path in the batch should match $(TargetPath) )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM