How to register a .NET assembly as COM?
Are you sure you have the right RegAsm
in your path since you're calling it by exe name only without specifying the full path? You must call the right version of RegAsm for it to work, i.e 32 or 64-bit version of .NET 4.
Try specifying the full path:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe /codebase F:\Workflow\WorkflowHandler\bin\debug\WorkflowHandler.dll
or
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe /codebase F:\Workflow\WorkflowHandler\bin\debug\WorkflowHandler.dll
Also I noticed that in the path to your assembly you had some /
characters instead of \
. Make sure you're putting in the correct path.
I'll expand on the accepted answer with my solution.
First, I ran into issues with "AnyCPU" (I have to interop with COM, hence my reason for doing this), so I limit platform to x86 and x64. I wanted it to register the component as part of the build, so I did this as a post build event:
if $(PlatformName) == x64 (
set RegAsm=$(MSBuildFrameworkToolsPath64)regasm.exe
) else (
set RegAsm=$(MSBuildFrameworkToolsPath)regasm.exe
)
echo Creating TypeLib
"%RegAsm%" /tlb "$(TargetPath)"
echo Registering Component
"%RegAsm%" "$(TargetPath)"
Note: This probably won't work for ia64. If you've got to make this work for one of those, you've got bigger problems than this, though. :-)