When to Register or UnRegister Assemblies

Got a problem you cannot solve? Try here.
Post Reply
MattWilkinson
Posts: 29
Joined: Thu Feb 11, 2010 7:05 am

When to Register or UnRegister Assemblies

Post by MattWilkinson »

I am using the Run Program command to register my .NET DLL for COM Interop as follows:

Code: Select all

Run Program $WINDIR$Microsoft.NET\Framework\v4.0.30319\RegAsm.exe "$TARGETDIR$\Bin\VizualData.dll" /codebase /silent
The problem I had however was that if I installed an older version of my package - it did not unregister the DLL correctly so I added an unregistration just before the

Code: Select all

Install/Remove MSI Package
command - in the section:

Code: Select all

if Variable NEEDSUPGRADE=TRUE
This has had the effect that it is now not correctly registering my files

Can someone tell me at which point(s) I should be
a) Registering files
b) Unregistering files

Thanks
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: When to Register or UnRegister Assemblies

Post by bokkie »

Matt, I've probably misunderstood your problem but in the InstallFiles command there's a checkbox that does the self-registering of DLLs. Is that of any help?
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
MattWilkinson
Posts: 29
Joined: Thu Feb 11, 2010 7:05 am

Re: When to Register or UnRegister Assemblies

Post by MattWilkinson »

Well that might help - the InstallAware help file doesn't give any clue as to what that does though:

Does it run RegAsm?
Which .NET framework RegAsm will it register it with? The latest found on the machine? The one used to build the assembly?
Does it register in the GAC or in the target location?
Does it register for COM Interop?

Who knows?

It is safer to call the commands myself - but my question is at which points in the script?
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: When to Register or UnRegister Assemblies

Post by giaviv »

Hi,

Please read about the Install Assembly command (or the Assembly section in the Design tab).
This command allows you to install an assembly, register it for COM interop, run regasm on it, run ngen on it, register it to the GAC and more.
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
MattWilkinson
Posts: 29
Joined: Thu Feb 11, 2010 7:05 am

Re: When to Register or UnRegister Assemblies

Post by MattWilkinson »

I have looked at this command however there some fundamental issues with this command:

The help file does not mention anything about regasm in the Install Assembly page:
There is no way to enable regasm in the MSICode tab and indeed you can't even see that it is enabled in this tab
There is no mention of how to invoke command line switches /codebase /tlb for example
Which framework version does it register against? The latest? The same one as the assembly?
What happens if the .NET framework is not installed? or regasm cannot be found

As usual the help file is severely lacking in content and the design and MSI code tab options differ.
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: When to Register or UnRegister Assemblies

Post by giaviv »

The Install Assembly command doesn't register and assembly, it only installs the actual file to the target machine.
The Register Assembly command, which is emitted by the IDE when you select register assembly in the Design tab, handles the registering of the assembly.
All the other options are there as well.

I am sorry you feel that our help files are lacking, but I beg to differ. By simply selecting regasm in the Design tab you could see the Register Assembly command being emitted. Also, you can search the help files for "register assembly" and read about the command.
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
MattWilkinson
Posts: 29
Joined: Thu Feb 11, 2010 7:05 am

Re: When to Register or UnRegister Assemblies

Post by MattWilkinson »

I'm sorry, but the help file does not mention anything about regasm in the Register Assembly page either!

So I assume that the 'Set codebase in the registry' is effectively using the /codebase switch?
Is there a way to invoke the /tlb switch?

Could you also please answer my earlier question regarding which framework version is used:
Which framework version does it register against?
The latest?
The same one as the assembly?
What about 64 bit frameworks / assemblies?

Thanks
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: When to Register or UnRegister Assemblies

Post by giaviv »

Hi,

Register Assembly is simply regasm.

Codebase does set the /codebase flag. There is no integrated way to run /tlb, you would have to use Run Program for that, and pass regasm.exe the /tlb flag.

About your other question, IA invokes the latest version of regasm available (and thr x64 version if exists).
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
MattWilkinson
Posts: 29
Joined: Thu Feb 11, 2010 7:05 am

Re: When to Register or UnRegister Assemblies

Post by MattWilkinson »

OK so I need to use run program then to use the /tlb switch which goes back to my original post:

At which point(s) I should be running regasm and which point(s) I should be running regasm /unregister

Also I believe that if you try to register a 32 bit assembly using regasm64 then this will fail so register assembly is flawed if it works as you described
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: When to Register or UnRegister Assemblies

Post by giaviv »

The correct bit version is invoked for the assembly so that the registration works.

If you are not using the Native Engine, call register after Apply Install, and unregister before Apply Uninstall.
Otherwise, call it after Install Assembly, or before Apply Uninstall
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Post Reply