Question

I have a dependency on several COM components. My project is managed. I want to ensure that the most recent version of the COM DLL is registered pre-build. I have added regsvr32 calls on the DLLs in the pre-build step but it never seems to work correctly. When the project is built it complains that the type isn't registered. I have both isolated and non-isolated components.

How do people handle this situation? Is regsvr32 the only answer? Why does MSBuild fail to notice that the types have been registered?

Was it helpful?

Solution

Regsvr32 is the way to register your typelib and COM server information in the registry. It's a trivial process, and I'm suprised that it doesn't work. Have you hand verified the process to make sure its not something else, like supplying the wrong path to regsvr32?

OTHER TIPS

I solved this problem by calling a batch script:

$(ProjectDir)register.bat "$(SolutionDir)"

Batch:

regsvr32 "%~1ThirdParty\comdll1.dll" /s
if %ERRORLEVEL% NEQ 0 GOTO Exit
regsvr32 "%~1ThirdParty\comdll2.dll" /s
if %ERRORLEVEL% NEQ 0 GOTO Exit
regsvr32 "%~1ThirdParty\comdll3.dll" /s
EXIT:

The issue is that Visual Studio can only check the ERRORLEVEL value once, at the end. If comdll2 failed to register but comdll3 succeeded then the ERRORLEVEL would be 0 and the build would not fail.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top