tags:

views:

37

answers:

2

Hello,

I have an assembly that has a lot of old registered versions.

The only dll I have is the last one.

How can I unregister all versions of the assembly?

Thanks.

EDIT : I want to do this at runtime so I want something like regasm -u... or some other script-y solution.

A: 

Use Regasm.exe /u [filename]

Aliostad
RegAsm /u [filname] will only remove the entries that match the version number of your assembly.
gil
A: 

EDIT: I'm assuming that there are associated registry entries that you are trying to remove.

Regasm can output a .reg file.

You can use the /regfile option to generate a .reg file that contains the registry entries instead of making the changes directly to the registry. You can update the registry on a computer by importing the .reg file with the Registry Editor tool (Regedit.exe).

If you want to uninstall old versions at runtime, presumably you could:

1) Create a reg file for the current assembly (for reference purposes).

2) Write an application that examined the registry for similar keys (perhaps with different version numbers?)

3) Use regasm to unregister matching assemblies. If necessary, uninstall COM entities with regsvr32.

4) CAREFULLY remove those keys programmatically.

5) Register your new assembly.

6) gacutil the newly registered assembly (if needed).

My COM/Interop is a little rusty, so please leave a comment if this doesn't work.

Tim
Sorry for not being clear. I want to do this at runtime.
gil
Then use a script to do that (enumerate the files in that folder, and run `regasm /u` on the ones you want to remove.
Allon Guralnek
@Allon - good point...there would still be the COM references to deal with.
Tim
@Tim: True. (My comment was supposed to be @gil, referring to the previous version of your answer).
Allon Guralnek