I want to run regasm.exe from cmd. which is available in c:windowsMicrosoft.netframework2.057
Edit registerforcom.BAT; Replace v2.0.50727 with the correct.NET framework your computer is using. Re-run registerforcom.BAT; Look for 'Type registered successfully'.
I do like this c: regasm.exe
It gives regasm is not recognized as internal or external command.
So I understood that I need to set the path for regasm.exe in environment variable.
For which variable do I need to set the path to run regasm as described above?
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.NETFrameworkv2.0.50727regasm.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:
If you created the DLL using .net 4.5 , then copy and paste this command on command prompt.
I use this as post-build event in Visual Studio:
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:
Outside of a bat file (i.e. command prompt), just use %a
instead of %%a
For the 64-bit RegAsm.exe you will need to find it someplace like this:
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. Scroll down in both windows so that you have a view of both the dll and 'regasm'.It helps to reduce the size of the two windows so they are side-by-side.Be sure to drag the dll over the 'regasm' that is labeled 'application'. There are several 'regasm' files but you only want the application.
Execute only 1 of the below
Once a command works, skip the rest/ below to it:
Normal:
Only if you face issues, use old version 'v2.0.50727':
Only if you built myTest.dll for 64bit Only, use 'Framework64' path:
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
Hey I tried adding a DLL file in Windows 7 by copying to system32 folder, but I couldn't as Access Was Denied. Actually there is an existing DLL file and I'm trying to replace it. How can I do this in Windows 7?
To register a dll, you open a command box as admin and then use regsvr32 /i <dll_name>
.
Tha said, your problem seems to be that you just can't copy the file. Again, open a command box as admin and do the following:
If the file is in use, you should do this in safe mode, command prompt only. If you hose your system, you can delete the dll you copied, and rename the .old back to .dll.
Unregister the existing DLL file first (with the /u
switch), and then register the DLL. This way, the un-registration routine will clean up the existing settings which often helps when re-registering.
To register a comm .dll or .ocx on Windows 7 32-bit, do the following:
Copy .dll or .ocx to c:windowssystem32
Type cmd
in Run menu, it will search cmd.exe
, right click and click Run as Administrator
It will show a prompt at c:windowssystem32
Type regsvr32 ocxname.ocx
to register .ocx
or
type regsvr32 dllname.dll
to register .dll
the regsvr32 located in SysWow64 folder is for 32bit dll
It's a strange naming from microsoft:WOW64 means 'windows [32bit] on windows 64bit'the one located in system32 is for 64bit dlls.
There are usually two issues with regsvr32 on Windows 7:
To get around the 'Access Denied' problem, start the command line as admin, in the start menu type 'cmd.exe' and then right click the 'cmd.exe' entry and 'Run as Administrator'.
If the DLL is 32bit and in the 32Bit Windows directory, use the 32bit version of regsvr32 at c:windowssysWOW64regsvr32.exe
If your Windows 7 is x64 and the DLL you want to register is x64 you may run regsvr32.exe
from C:WindowsSysWOW64
.
Example: