I want to run regasm.exe from cmd. which is available in c:\\windows\\Microsoft.net\\framework\\2.057
I do like this c:\\ regasm.exe
It gives regasm is n
You don't need the directory on your path. You could put it on your path, but you don't NEED to do that.
If you are calling regasm rarely, or calling it from a batch file, you may find it is simpler to just invoke regasm via the fully-qualified pathname on the exe, eg:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe MyAssembly.dll
If you created the DLL using .net 4.5 , then copy and paste this command on command prompt.
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\regasm.exe MyAssembly.dll
I use this as post-build event in Visual Studio:
call "%VS90COMNTOOLS%vsvars32.bat"
regasm $(TargetPath) /tlb
Depending on your Visual Studio version, use these environment variables instead:
VS90COMNTOOLS
VS100COMNTOOLS
VS110COMNTOOLS
VS120COMNTOOLS
VS140COMNTOOLS
VS150COMNTOOLS
I really dislike the hard coding of paths to get to regasm, when you install a new .Net or run on a machine with a different version, you need to ensure you find a version of regasm. Here's a solution to find the regasm.exe from the most current .Net installed regasm.
Within a bat file:
for /f %%a in ('dir %windir%\Microsoft.Net\Framework\regasm.exe /s /b') do set currentRegasm="%%a"
%currentRegasm% "full\path\to\your.dll" /options
Outside of a bat file (i.e. command prompt), just use %a
instead of %%a
Like Cheeso said:
You don't need the directory on your path. You could put it on your path, but you don't NEED to do that. If you are calling regasm rarely, or calling it from a batch file, you may find it is simpler to just invoke regasm via the fully-qualified pathname on the exe, eg:
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\regasm.exe MyAssembly.dll
Execute only 1 of the below
Once a command works, skip the rest/ below to it:
Normal:
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe myTest.dll
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe myTest.dll /tlb:myTest.tlb
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe myTest.dll /tlb:myTest.tlb /codebase
Only if you face issues, use old version 'v2.0.50727':
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe myTest.dll
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe myTest.dll /tlb:myTest.tlb
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe myTest.dll /tlb:myTest.tlb
Only if you built myTest.dll for 64bit Only, use 'Framework64' path:
%SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe myTest.dll
%SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\RegAsm.exe myTest.dll
Note: 64-bit built dlls will not work on 32-bit platform.
All options:
See https://docs.microsoft.com/en-us/dotnet/framework/tools/regasm-exe-assembly-registration-tool