To execute RegAsm.exe, open a command prompt window, and navigate to the folder where RegAsm.exe is located and run it (otherwise you will get "RegAsm is not recognized as internal or external command, operable program or batch file" error message).
By dragging and dropping the dll onto 'regasm' you can register it. You can open two 'Window Explorer' windows. One will contain the dll you wish to register. The 2nd window will be the location of the 'regasm' application.
The file RegAsm.exe is located in a subfolder of C:\Windows or sometimes in a subfolder of the user's profile folder (for instance C:\Windows\Microsoft.NET\Framework\v4. 0.30319\).
You can use the Developer Command Prompt for Visual Studio to access the compiler from any directory on your machine, if Visual Studio is installed. Invoke the Developer Command Prompt for Visual Studio. At the command line, type vbc.exe sourceFileName and then press ENTER.
In command prompt:
SET PATH = "%PATH%;%SystemRoot%\Microsoft.NET\Framework\v2.0.50727"
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
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 use the following in a batch file:
path = %path%;C:\Windows\Microsoft.NET\Framework\v2.0.50727
regasm httpHelper\bin\Debug\httpHelper.dll /tlb:.\httpHelper.tlb /codebase
pause
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With